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
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