[cairo] Trouble displaying a jpeg image
Jeffrey Britton
jeffb0098 at gmail.com
Sat Jan 7 19:14:38 PST 2012
Thanks.
In case it helps anybody, the following ended up being the fastest and most
direct method that I could work out.
Nonetheless, the conversion from rgb to bgra is quite slow(150ms on my
single core 2.9Ghz machine) and should be done in 'C'.
I tried Cython with no signifcant improvement.
img = Image.open(fn)
l = [struct.pack('BBBB', b, g, r, 0xFF) for (r,g,b) in img.getdata()]
s = string.join(l, '')
self.img = array.array('B', s)
stride = cairo.ImageSurface.format_stride_for_width(cairo.FORMAT_ARGB32,
self.width())
self.img_surface = cairo.ImageSurface.create_for_data (self.img,
cairo.FORMAT_ARGB32, self.width(), self.height(), stride)
On Sat, Jan 7, 2012 at 1:20 AM, Vicky Tux <ssseintr2 at gmail.com> wrote:
>
> As per my understanding there is no jpeg image decoder in cairo. only png
> surfaces were supported.
> -vicky
>
>>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120107/493781c4/attachment.html>
More information about the cairo
mailing list