Exemple #1
0
 def __init__(self, *arg):
     """
     Return Surface that is subclassed from java.awt.image.BufferedImage.
     
     Alternative arguments:
     
     * Size (w,h) of surface, optional second argument of flags (SRCALPHA)
     * Bufferedimage to convert to Surface
     
     Module initialization places pyj2d.Surface in module's namespace.
     """
     try:
         width, height = arg[0]
         try:
             if arg[1] & (BufferedImage.TYPE_INT_ARGB | Const.SRCALPHA):
                 BufferedImage.__init__(self, width, height,
                                        BufferedImage.TYPE_INT_ARGB)
             else:
                 BufferedImage.__init__(self, width, height,
                                        BufferedImage.TYPE_INT_RGB)
         except IndexError:
             BufferedImage.__init__(self, width, height,
                                    BufferedImage.TYPE_INT_ARGB)
             graphics2D = self.createGraphics()
             graphics2D.setColor(Color(0,0,0))
             graphics2D.fillRect(0, 0, width, height)
             graphics2D.dispose()
     except TypeError:
         try:
             cm = arg[0].getColorModel()
             raster = arg[0].getRaster()
             isRasterPremultiplied = arg[0].isAlphaPremultiplied()
             properties = Hashtable()
             keys = arg[0].getPropertyNames()
             if keys != None:
                 for key in keys:
                     properties.put(key, arg[0].getProperty(key))
         except AttributeError:
             cm, raster, isRasterPremultiplied, properties = arg
         BufferedImage.__init__(self, cm, raster,
                                isRasterPremultiplied, properties)
     self._display = None    #display surface
     self._super_surface = None
     self._offset = (0,0)
     self._colorkey = None
     self._nonimplemented_methods()
Exemple #2
0
 def __init__(self, *arg):
     """
     Return Surface that is subclassed from java.awt.image.BufferedImage.
     
     Alternative arguments:
     
     * Size (w,h) of surface, optional second argument of flags (SRCALPHA)
     * Bufferedimage to convert to Surface
     
     Module initialization places pyj2d.Surface in module's namespace.
     """
     try:
         width, height = arg[0]
         try:
             if arg[1] & (BufferedImage.TYPE_INT_ARGB | Const.SRCALPHA):
                 BufferedImage.__init__(self, width, height, BufferedImage.TYPE_INT_ARGB)
             else:
                 BufferedImage.__init__(self, width, height, BufferedImage.TYPE_INT_RGB)
         except IndexError:
             BufferedImage.__init__(self, width, height, BufferedImage.TYPE_INT_ARGB)
             graphics2D = self.createGraphics()
             graphics2D.setColor(Color(0,0,0))
             graphics2D.fillRect(0, 0, width, height)
             graphics2D.dispose()
     except TypeError:
         try:
             cm = arg[0].getColorModel()
             raster = arg[0].getRaster()
             isRasterPremultiplied = arg[0].isAlphaPremultiplied()
             properties = Hashtable()
             keys = arg[0].getPropertyNames()
             if keys != None:
                 for key in keys:
                     properties.put(key,arg[0].getProperty(key))
         except AttributeError:
             cm, raster, isRasterPremultiplied, properties = arg
         BufferedImage.__init__(self, cm, raster, isRasterPremultiplied, properties)
     self._display = None    #display surface
     self._super_surface = None
     self._offset = (0,0)
     self._colorkey = None
     self._nonimplemented_methods()