Beispiel #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)
Beispiel #2
0
class PyImageAlpha(Ndarray):
    """
    Array consists of pixel data arranged by width/height of pixel alpha value.
    Array data derived from ImageData.
    """
    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)

    def getImageData(self):
        index = 0
        for x in xrange(self.__imagedata.height):
            for y in xrange(self.__imagedata.width):
                self.__imagedata.data[index + 3] = self[y, x]
                index += 4
        return self.__imagedata.getImageData()
Beispiel #3
0
class PyImageInteger(Ndarray):
    """
    Array consists of pixel data arranged by width/height in integer color format.
    Array data derived from ImageData.
    """
    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)

    def getImageData(self):
        index = 0
        for x in xrange(self.__imagedata.height):
            for y in xrange(self.__imagedata.width):
                self.__imagedata.data[index], self.__imagedata.data[
                    index + 1], self.__imagedata.data[
                        index + 2], self.__imagedata.data[index + 3] = self[
                            y, x] >> 16 & 0xff, self[y, x] >> 8 & 0xff, self[
                                y, x] & 0xff, self[y, x] >> 24 & 0xff
                index += 4
        return self.__imagedata.getImageData()
class PyImageInteger(Ndarray):
    """
    Array consists of pixel data arranged by width/height in integer color format.
    Array data derived from ImageData.
    """

    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)

    def getImageData(self):
        index = 0
        for x in xrange(self.__imagedata.height):
            for y in xrange(self.__imagedata.width):
                self.__imagedata.data[index], self.__imagedata.data[index+1], self.__imagedata.data[index+2], self.__imagedata.data[index+3] = self[y,x]>>16 & 0xff, self[y,x]>>8 & 0xff, self[y,x] & 0xff, self[y,x]>>24 & 0xff
                index += 4
        return self.__imagedata.getImageData()
class PyImageAlpha(Ndarray):
    """
    Array consists of pixel data arranged by width/height of pixel alpha value.
    Array data derived from ImageData.
    """

    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)

    def getImageData(self):
        index = 0
        for x in xrange(self.__imagedata.height):
            for y in xrange(self.__imagedata.width):
                self.__imagedata.data[index+3] = self[y,x]
                index += 4
        return self.__imagedata.getImageData()
Beispiel #6
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)
 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)
 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)