[cairo] How to load a BMP/JPG/TGA to a Surface?
adrianlopezroche at gmail.com
Tue Jun 1 13:41:27 PDT 2010
Something I forgot to add concerning the use of DevIL with Cairo: While
Cairo's ARGB32 format uses premultiplied alpha , DevIL's format does not.
Thus, when converting from DevIL's format to Cairo's format you first have
to multiply the R, G and B components by the pixel's normalized alpha value
(which is A / 255.0 for an 8-bit alpha value).
On Tue, Jun 1, 2010 at 4:09 PM, Adrian Lopez <adrianlopezroche at gmail.com>wrote:
> On Tue, Jun 1, 2010 at 12:35 AM, Mj Mendoza IV <mjmendoza at konsolscript.org
> > wrote:
>> Is there any way that I could load BMP/JPG/TGA without being tied to a
>> specific library to avoid bloat? Is there a minimalist reusable 'standalone'
>> function that directly loads a BMP/JPG/TGA into the memory which cairo could
> I load images into memory using DevIL  and copy them from memory onto a
> Cairo image surface, translating from DevIL's IL_RGBA format to Cairo's
> CAIRO_FORMAT_ARGB32 . Cairo has no built-in support for most image
> formats, so your only options are to use a third party library like DevIL or
> write your own image loading routines.
>  http://openil.sourceforge.net/
>  Something to look out for if you decide to do this: While the order of
> pixel components in Cairo's image format is affected by endianness, the
> order of components in DevIL is not. Thus, on x86 systems it turns out that
> while DevIL's format looks like (R, G, B, A), Cairo's format actually looks
> like (B, G, R, A).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cairo