当前位置: 首页>>代码示例>>Python>>正文


Python BufferedImage.createGraphics方法代码示例

本文整理汇总了Python中java.awt.image.BufferedImage.createGraphics方法的典型用法代码示例。如果您正苦于以下问题:Python BufferedImage.createGraphics方法的具体用法?Python BufferedImage.createGraphics怎么用?Python BufferedImage.createGraphics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.image.BufferedImage的用法示例。


在下文中一共展示了BufferedImage.createGraphics方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_font_metrics

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
def get_font_metrics(font_name, font_size):
    from java.awt.image import BufferedImage
    from java.awt import Font

    tmp_img = BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)
    g = tmp_img.createGraphics()
    return g.getFontMetrics((Font(font_name, Font.PLAIN, int(font_size))))
开发者ID:kiwiroy,项目名称:nodebox,代码行数:9,代码来源:pyvector.py

示例2: resize

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
 def resize(self, image, width, height):
     bi = BufferedImage(width, height, BufferedImage.TRANSLUCENT)
     g2d = bi.createGraphics()
     g2d.addRenderingHints(RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY))
     g2d.drawImage(image, 0, 0, width, height, None)
     g2d.dispose()
     return bi;
开发者ID:anhnt4288,项目名称:PT-Manager,代码行数:9,代码来源:PTManager.py

示例3: getScreenPanel

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
def getScreenPanel():
    global mainScreen
    global scrPanel
    if not scrPanel:
        mainScreen = JButton()
        cursorImg = BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB)
        blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, Point(0,0), "blank cursor")
        mainScreen.setCursor(blankCursor)
        mainScreen.setPreferredSize(
                Dimension(700, 700))
        image = BufferedImage(700, 700, BufferedImage.TYPE_INT_ARGB)
        g = image.createGraphics()
        g.setColor(Color.BLACK)
        g.fillRect(0, 0, 700, 700)
        g.setColor(Color.WHITE)
        g.setFont(Font("Serif", Font.BOLD, 20))
        g.drawString("Move your mouse here to controlfocused device.", 50, 30)
        mainScreenImg = image
        mainScreen.setIcon(swing.ImageIcon(image))

        mouseListener = ScrMouseListener()
        mainScreen.addMouseListener(mouseListener)
        mainScreen.addMouseMotionListener(mouseListener)
        mainScreen.addMouseWheelListener(mouseListener)

        mainScreen.setFocusable(True)
        keyListener = ScrKeyListener()
        mainScreen.addKeyListener(keyListener)


        scrPanel = JPanel()
        scrPanel.setLayout(BoxLayout(scrPanel, BoxLayout.Y_AXIS))
        scrPanel.add(mainScreen)
        scrPanel.setFocusable(True)
    return scrPanel
开发者ID:sjp38,项目名称:ash,代码行数:37,代码来源:ashdi.py

示例4: outputFiles

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
 def outputFiles(self, filename, attachLogo=False, logoText=None):
     rendered = self.getTarget().screenshot()
     if attachLogo:
         from java.awt.image import BufferedImage
         from com.raytheon.uf.common.localization import PathManagerFactory
         noaa = 'pyViz/logos/noaalogo2.png'
         nws = 'pyViz/logos/nwslogo.png'
         pathMgr = PathManagerFactory.getPathManager()
         noaa = pathMgr.getStaticFile(noaa)
         nws = pathMgr.getStaticFile(nws)
         noaaImage = ImageIO.read(noaa)
         nwsImage = ImageIO.read(nws)
         height = rendered.getHeight() + noaaImage.getHeight()
         finalBuf = BufferedImage(rendered.getWidth(), height, BufferedImage.TYPE_INT_ARGB)
         graphics = finalBuf.createGraphics()
         graphics.drawImage(rendered, 0, 0, None)
         graphics.drawImage(noaaImage, 0, rendered.getHeight(), None)
         graphics.fillRect(noaaImage.getWidth(), rendered.getHeight(), rendered.getWidth() - noaaImage.getWidth() - nwsImage.getWidth(), rendered.getHeight())
         if logoText is not None:
             from java.awt import Color
             from com.raytheon.uf.viz.core.font import FontAdapter
             graphics.setColor(Color.BLACK)
             graphics.setFont(FontAdapter.getAWTFont(self.getTarget().getDefaultFont()))
             fm = graphics.getFontMetrics()
             textBounds = fm.getStringBounds(logoText, graphics)
             graphics.drawString(logoText, int((rendered.getWidth() - textBounds.getWidth()) / 2), \
                                 int(rendered.getHeight() + (noaaImage.getHeight() / 2) + textBounds.getHeight() / 2))
         graphics.drawImage(nwsImage, finalBuf.getWidth() - nwsImage.getWidth(), rendered.getHeight(), None)
         finalBuf.flush()
         self.outputImage(finalBuf, filename)
     else:
         self.outputImage(rendered, filename)
开发者ID:KeithLatteri,项目名称:awips2,代码行数:34,代码来源:GFEPainter.py

示例5: scale_to_fill

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
def scale_to_fill(buffered_image):
    raster = buffered_image.getData()
    width = raster.getWidth()
    height = raster.getHeight()
    #Get extreem values from the image
    max_x = 0
    min_x = width
    max_y = 0
    min_y = height
    for x in range(0, width):
        for y in range(0,height):
            color = pixel_has_color(x,y, raster)
            if(color):
                if x > max_x:
                    max_x = x
                if x < min_x:
                    min_x = x
                if y > max_y:
                    max_y = y
                if y < min_y:
                    min_y = y
    #Cut out the part of image containing colored pixels
    sub_image = buffered_image.getSubimage(min_x, min_y, max_x-min_x+1,max_y-min_y+1)
    #Scale the image
    resized_image = BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY)
    g = resized_image.createGraphics()
    g.drawImage(sub_image, 0, 0, width, height, None)
    g.dispose()
    return resized_image
开发者ID:Jonny-James,项目名称:HandReco,代码行数:31,代码来源:image_preprocessor.py

示例6: PyColorButton

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
class PyColorButton(JButton):
        def __init__(self, color, action=None):
            JButton.__init__(self)
            self._image = BufferedImage(70, 12, BufferedImage.TYPE_INT_ARGB)
            g = self._image.createGraphics()
            g.setColor(color)
            g.fillRect(0, 0, self._image.width, self._image.height)
            self._icon = ImageIcon(self._image)
            self.icon = self._icon
            if action is not None:
                self.actionPerformed = action
    
        def set_color(self, color):
            g = self._image.createGraphics()
            g.setColor(color)
            g.fillRect(0, 0, self._image.width, self._image.height)
            self._icon = ImageIcon(self._image)
            self.icon = self._icon
开发者ID:ak1394,项目名称:bookshelf,代码行数:20,代码来源:gui.py

示例7: resizeImage

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
 def resizeImage(self, fullSizeImage):
     bufferedImage = BufferedImage(SwingingMonkeyCommander._preferredWidth, SwingingMonkeyCommander._preferredHeight, BufferedImage.TRANSLUCENT)
     graphics2d = bufferedImage.createGraphics()
     graphics2d.addRenderingHints(RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY))
     graphics2d.drawImage(fullSizeImage, 0, 0, SwingingMonkeyCommander._preferredWidth, SwingingMonkeyCommander._preferredHeight, None)
     graphics2d.dispose()
     SwingingMonkeyCommander._widthScale = float(fullSizeImage.getWidth()) / float(bufferedImage.getWidth())
     SwingingMonkeyCommander._heightScale = float(fullSizeImage.getHeight()) / float(bufferedImage.getHeight())
     return bufferedImage
开发者ID:fejd,项目名称:SwingingMonkeyCommander,代码行数:11,代码来源:SwingingMonkeyCommander.py

示例8: saveToPNG

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
def saveToPNG(p,filename):
    from java.awt.image import BufferedImage
    from javax.imageio import ImageIO
    from java.io import File
    bi = BufferedImage(p.size.width, p.size.height, BufferedImage.TYPE_INT_ARGB) 
    g = bi.createGraphics()
    p.invalidate()
    p.validate()
    p.paint(g)
    g.dispose();
    ImageIO.write(bi,"png", File(filename));
开发者ID:CalSimCalLite,项目名称:CalLiteGUI,代码行数:13,代码来源:calibration_compare_plots.py

示例9: snapshot

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
def snapshot(frame, box):
    bi = BufferedImage(box.width, box.height, BufferedImage.TYPE_INT_RGB)
    g = bi.createGraphics()
    g.translate(-box.x, -box.y)
    # all black! # frame.paintAll(g)
    # only swing components! # frame.paint(g)
    # only swing components! # frame.update(g)
    # together, also only swing and with errors
    ##frame.update(g)
    ##frame.paint(g)
    # locks the entire graphics machinery # frame.printAll(g)
    # Finally, the right one:
    SwingUtilities.invokeAndWait(PrintAll(frame, g))
    return bi
开发者ID:Mverp,项目名称:fiji,代码行数:16,代码来源:Record_Window.py

示例10: save_as_png

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
def save_as_png(p,filename):
    """
    saves plot window (G2Dialog) created by newPlot(title) method as a png graphics file
    """
    from java.awt.image import BufferedImage
    from javax.imageio import ImageIO
    from java.io import File
    bi = BufferedImage(p.size.width, p.size.height, BufferedImage.TYPE_INT_ARGB) 
    g = bi.createGraphics()
    p.invalidate()
    p.validate()
    p.paint(g)
    g.dispose();
    ImageIO.write(bi,"png", File(filename));
开发者ID:CalSimCalLite,项目名称:CalLiteGUI,代码行数:16,代码来源:model_obs_compare.py

示例11: getContentPane

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
def getContentPane():
    global contentPane
    global REMAP_WIDTH
    global REMAP_HEIGHT
    global MARGIN
    if not contentPane:
        global mainScreen
        global mainScreenImg
        mainScreen = JLabel()

        cursorImg = BufferedImage(16,16,BufferedImage.TYPE_INT_ARGB)
        blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImg, Point(0,0), "blank cursor")
        mainScreen.setCursor(blankCursor)
        mainScreen.setPreferredSize(
                Dimension(REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN))
        mainScreen.setText("main screen!")
        image = BufferedImage(REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN
                , BufferedImage.TYPE_INT_ARGB)
        g = image.createGraphics()
        g.setColor(Color.BLACK)
        g.fillRect(0, 0, REMAP_WIDTH + MARGIN, REMAP_HEIGHT + MARGIN)
        g.setColor(Color.WHITE)
        g.setFont(Font("Serif", Font.BOLD, 20))
        g.drawString("Cursor will display on your device.", 50, 30)
        mainScreenImg = image
        mainScreen.setIcon(swing.ImageIcon(image))

        mouseListener = ScrMouseListener()
        mainScreen.addMouseListener(mouseListener)
        mainScreen.addMouseMotionListener(mouseListener)
        mainScreen.addMouseWheelListener(mouseListener)

        keyListener = ScrKeyListener()
        mainScreen.addKeyListener(keyListener)
        
        mainScreen.setFocusable(True)

        scrPanel = JPanel()
        scrPanel.setLayout(BoxLayout(scrPanel, BoxLayout.Y_AXIS))
        scrPanel.add(mainScreen)


        contentPane = JPanel()
        contentPane.setLayout(BorderLayout())
        contentPane.add(scrPanel, BorderLayout.WEST)
#        contentPAne.add(controlPanel(). BorderLayout.EAST)

    return contentPane
开发者ID:JeKim,项目名称:MonkeyPySon,代码行数:50,代码来源:monkeypyson.py

示例12: get_image

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
    def get_image(self):
        """Generate a BufferedImage representing the current environment, for use in
        interactivemode display."""

        # copy map
        bitmap = BufferedImage(self.map.getColorModel(), self.map.copyData(None), False, None);

        # draw agent
        graphics = bitmap.createGraphics()
        graphics.setColor(Color.orange)
        agentsize = 0.2
        x, y = self.pt_to_pixel((self.state[0] - agentsize / 2, self.state[1] + agentsize / 2))

        graphics.fillRect(x, y, int(agentsize * bitmap.getWidth() / self.imgsize[0]), int(agentsize * bitmap.getHeight() / self.imgsize[1]))

        return bitmap
开发者ID:Seanny123,项目名称:HRL_1.0,代码行数:18,代码来源:placecell_bmp.py

示例13: run

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
 def run(self):
     System.out.println("run")
     # zero-pad up to 10 digits
     bi = None
     try:
         title = str(self.i)
         while len(title) < 10:
             title = "0" + title
         bi = BufferedImage(self.bounds.width, self.bounds.height, BufferedImage.TYPE_INT_RGB)
         g = bi.createGraphics()
         g.drawImage(self.borders, 0, 0, None)
         g.drawImage(self.img, self.insets.left, self.insets.top, None)
         FileSaver(ImagePlus(title, ColorProcessor(bi))).saveAsTiff(self.dir + title + ".tif")
     except Exception, e:
         print e
         e.printStackTrace()
开发者ID:Mverp,项目名称:fiji,代码行数:18,代码来源:Record_Window.py

示例14: addSS

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
 def addSS(self,event):
     clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
     try:
         image = clipboard.getData(DataFlavor.imageFlavor)
     except:
         self.popup("Clipboard not contains image")
         return
     vulnPath = self.projPath.getText() + "/" + self.clearStr(self.vulnName.getText())
     if not os.path.exists(vulnPath):
         os.makedirs(vulnPath)
     name = self.clearStr(self.vulnName.getText()) + str(random.randint(1, 99999))+".jpg"
     fileName = self.projPath.getText()+"/"+ self.clearStr(self.vulnName.getText()) + "/" + name
     file = File(fileName)
     bufferedImage = BufferedImage(image.getWidth(None), image.getHeight(None), BufferedImage.TYPE_INT_RGB);
     g = bufferedImage.createGraphics();
     g.drawImage(image, 0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), Color.WHITE, None);
     ImageIO.write(bufferedImage, "jpg", file)
     self.addVuln(self)
     self.ssList.setSelectedValue(name,True)
开发者ID:anhnt4288,项目名称:PT-Manager,代码行数:21,代码来源:PTManager.py

示例15: split_image

# 需要导入模块: from java.awt.image import BufferedImage [as 别名]
# 或者: from java.awt.image.BufferedImage import createGraphics [as 别名]
def split_image(image, length):
    piece_width = image.getWidth() / length
    piece_height = image.getHeight() / length

    images = []

    for i in range(length):
        for j in range(length):
            split = BufferedImage(piece_width, piece_height, image.getType())
            g = split.createGraphics()
            g.drawImage(image, 0, 0 ,\
                piece_width,\
                piece_height,\
                piece_width * j,\
                piece_height * i,\
                piece_width * j + piece_width,\
                piece_height * i + piece_height,\
                None);
            g.dispose();
            images.append(split)

    return images;
开发者ID:pythonoob,项目名称:SimplePyzzle,代码行数:24,代码来源:Splitter.py


注:本文中的java.awt.image.BufferedImage.createGraphics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。