Ejemplo n.º 1
0
 def __init__(self, imagedata):
     self.__imagedata = PyImageData(imagedata)
     array = Ndarray(self.__imagedata.data)
     array.setshape(self.__imagedata.height, self.__imagedata.width, 4)
     data = PyUint32Array(self.__imagedata.height * self.__imagedata.width)
     index = 0
     for x in xrange(self.__imagedata.width):
         for y in xrange(self.__imagedata.height):
             data[index] = array[y, x, 0] << 16 | array[
                 y, x, 1] << 8 | array[y, x, 2] | array[y, x, 3] << 24
             index += 1
     Ndarray.__init__(self, data, 3)
     self.setshape(self.__imagedata.width, self.__imagedata.height)
Ejemplo n.º 2
0
 def __init__(self, imagedata):
     self.__imagedata = PyImageData(imagedata)
     array = Ndarray(self.__imagedata.data)
     array.setshape(self.__imagedata.height, self.__imagedata.width, 4)
     try:
         data = PyUint8ClampedArray(self.__imagedata.height *
                                    self.__imagedata.width)
     except NotImplementedError:  #ie10 supports typedarray, not uint8clampedarray
         data = PyUint8Array(self.__imagedata.height *
                             self.__imagedata.width)
     index = 0
     for x in xrange(self.__imagedata.width):
         for y in xrange(self.__imagedata.height):
             data[index] = array[y, x, 3]
             index += 1
     try:
         Ndarray.__init__(self, data, 0)
     except NotImplementedError:
         Ndarray.__init__(self, data, 1)
     self.setshape(self.__imagedata.width, self.__imagedata.height)