Exemplo 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)
Exemplo 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
Exemplo 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
Exemplo 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))
Exemplo 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
Exemplo n.º 6
0
 def __setitem__(self, index, value):
     return PyImageMatrix.__setitem__(self, (index[1], index[0], 3), value)
Exemplo n.º 7
0
 def __getitem__(self, index):
     return PyImageMatrix.__getitem__(self, (index[1], index[0], 3))
Exemplo 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)
Exemplo 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))
Exemplo 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
Exemplo n.º 11
0
 def __setitem__(self, index, value):
     return PyImageMatrix.__setitem__(self, (index[1],index[0],3), value)
Exemplo n.º 12
0
 def __getitem__(self, index):
     return PyImageMatrix.__getitem__(self, (index[1],index[0],3))
Exemplo 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)