[cairo] How to load a BMP/JPG/TGA to a Surface?

Adrian Lopez adrianlopezroche at gmail.com
Tue Jun 1 13:09:56 PDT 2010


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
> use?
>

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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20100601/f49f6f12/attachment.htm>


More information about the cairo mailing list