示例#1
0
 def color(self):
     # XXX this needs to do something special to handle non-rgba images
     if self._pixel == ffi.NULL:
         raise ValueError("Pixel has expired")
     array = ffi.new("double[]", 4)
     lib.sanpera_pixel_to_doubles(self._pixel, array)
     return RGBColor(*array)
示例#2
0
文件: color.py 项目: eevee/sanpera
    def _from_pixel(cls, pixel):
        """Create a color from a PixelPacket."""
        array = ffi.new("double[]", 4)
        lib.sanpera_pixel_to_doubles(pixel, array)

        # Okay, yes, this isn't much of a classmethod.  TODO?
        return RGBColor._from_c_array(array)
示例#3
0
 def color(self):
     # XXX this needs to do something special to handle non-rgba images
     if self._pixel == ffi.NULL:
         raise ValueError("Pixel has expired")
     array = ffi.new("double[]", 4)
     lib.sanpera_pixel_to_doubles(self._pixel, array)
     return RGBColor(*array)
示例#4
0
    def _from_pixel(cls, pixel):
        """Create a color from a PixelPacket."""
        array = ffi.new("double[]", 4)
        lib.sanpera_pixel_to_doubles(pixel, array)

        # Okay, yes, this isn't much of a classmethod.  TODO?
        return RGBColor._from_c_array(array)
示例#5
0
    def __getitem__(self, point):
        point = Vector.coerce(point)

        px = ffi.new("PixelPacket *")

        # TODO retval is t/f
        with magick_try() as exc:
            lib.GetOneCacheViewAuthenticPixel(self._ptr, point.x, point.y, px, exc.ptr)

        array = ffi.new("double[]", 4)
        lib.sanpera_pixel_to_doubles(px, array)
        return RGBColor(*array)
示例#6
0
    def __getitem__(self, point):
        point = Vector.coerce(point)

        px = ffi.new("PixelPacket *")

        # TODO retval is t/f
        with magick_try() as exc:
            lib.GetOneCacheViewAuthenticPixel(self._ptr, point.x, point.y, px,
                                              exc.ptr)

        array = ffi.new("double[]", 4)
        lib.sanpera_pixel_to_doubles(px, array)
        return RGBColor(*array)