Esempio n. 1
0
 def array(self, surface):
     """
     Return data array of the Surface argument.
     Array consists of pixel data arranged by [y,x] in RGBA format.
     Data array most consistent to ImageData format.
     """
     imagedata = surface.impl.getImageData(0, 0, surface.width,
                                           surface.height)
     return PyImageMatrix(imagedata)
Esempio n. 2
0
 def blit_array(self, surface, array):
     """
     Generates image pixels from array data.
     Arguments include surface to generate the image, and array containing image data.
     """
     try:
         imagedata = array.getImageData()
     except (TypeError, AttributeError):     #-O/-S: TypeError/AttributeError
         imagedata = surface.impl.getImageData(0, 0, surface.width, surface.height)
         if len(array._shape) == 2:
             array2d = PyImageMatrix(imagedata)
             for y in xrange(array2d.getHeight()):
                 for x in xrange(array2d.getWidth()):
                     value = array[x,y]
                     array2d[y,x] = (value>>16 & 0xff, value>>8 & 0xff, value & 0xff, 255)
             imagedata = array2d.getImageData()
         else:
             imagedata.data.set(array.getArray())
     surface.impl.putImageData(imagedata, 0, 0, 0, 0, surface.width, surface.height)
     return None
Esempio n. 3
0
 def blit_array(self, surface, array):
     """
     Generates image pixels from array data.
     Arguments include surface to generate the image, and array containing image data.
     """
     try:
         imagedata = array.getImageData()
     except (TypeError, AttributeError):  #-O/-S: TypeError/AttributeError
         imagedata = surface.impl.getImageData(0, 0, surface.width,
                                               surface.height)
         if len(array._shape) == 2:
             array2d = PyImageMatrix(imagedata)
             for y in xrange(array2d.getHeight()):
                 for x in xrange(array2d.getWidth()):
                     value = array[x, y]
                     array2d[y, x] = (value >> 16 & 0xff, value >> 8 & 0xff,
                                      value & 0xff, 255)
             imagedata = array2d.getImageData()
         else:
             imagedata.data.set(array.getArray())
     surface.impl.putImageData(imagedata, 0, 0, 0, 0, surface.width,
                               surface.height)
     return None
Esempio n. 4
0
 def __setitem__(self, index, value):
     return PyImageMatrix.__setitem__(
         self, (index[1], index[0]), (value >> 16 & 0xff, value >> 8 & 0xff,
                                      value & 0xff, value >> 24 & 0xff))
Esempio n. 5
0
 def __getitem__(self, index):
     value = PyImageMatrix.__getitem__(self, (index[1], index[0]))
     return value[0] << 16 | value[1] << 8 | value[2] | value[3] << 24
Esempio n. 6
0
 def __setitem__(self, index, value):
     return PyImageMatrix.__setitem__(self, (index[1], index[0], 3), value)
Esempio n. 7
0
 def __getitem__(self, index):
     return PyImageMatrix.__getitem__(self, (index[1], index[0], 3))
Esempio n. 8
0
 def __setitem__(self, index, value):
     index = list(index)
     index[0], index[1] = index[1], index[0]
     index = tuple(index)
     return PyImageMatrix.__setitem__(self, index, value)
Esempio n. 9
0
 def __setitem__(self, index, value):
     return PyImageMatrix.__setitem__(self, (index[1],index[0]), (value>>16 & 0xff, value>>8 & 0xff, value & 0xff, value>>24 & 0xff))
Esempio n. 10
0
 def __getitem__(self, index):
     value = PyImageMatrix.__getitem__(self, (index[1],index[0]))
     return value[0]<<16 | value[1]<<8 | value[2] | value[3]<<24
Esempio n. 11
0
 def __setitem__(self, index, value):
     return PyImageMatrix.__setitem__(self, (index[1],index[0],3), value)
Esempio n. 12
0
 def __getitem__(self, index):
     return PyImageMatrix.__getitem__(self, (index[1],index[0],3))
Esempio n. 13
0
 def __setitem__(self, index, value):
     index = list(index)
     index[0], index[1] = index[1], index[0]
     index = tuple(index)
     return PyImageMatrix.__setitem__(self, index, value)