[cairo] How to load a BMP/JPG/TGA to a Surface?
Bill Spitzak
spitzak at gmail.com
Tue Jun 1 13:29:51 PDT 2010
Actually Cairo's image format is ARGB32, meaning each 32-bit word has
the bits arranged so that A is the high-order 8 bits and B in the lowest
8 bits. On a little-endian machine the bytes are then arranged in BGRA
order, but on a big-endian machine they would be ARGB.
I think DevIL will need to be changed. ARGB32 is used extensively and is
often the only or most-accelerated option on graphics hardware, due to
it being the format used by the Windows API.
Adrian Lopez wrote:
> I load images into memory using DevIL [1] and copy them from memory onto
> a Cairo image surface, translating from DevIL's IL_RGBA format to
> Cairo's CAIRO_FORMAT_ARGB32 [2]. 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.
>
> [1] http://openil.sourceforge.net/
> [2] 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).
More information about the cairo
mailing list