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