Something I forgot to add concerning the use of DevIL with Cairo: While Cairo's ARGB32 format uses premultiplied alpha [1], 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).<br>
<br>[1] <a href="http://www.gimp.org/docs/plug-in/appendix-alpha.html">http://www.gimp.org/docs/plug-in/appendix-alpha.html</a><br><br><div class="gmail_quote">On Tue, Jun 1, 2010 at 4:09 PM, Adrian Lopez <span dir="ltr"><<a href="mailto:adrianlopezroche@gmail.com">adrianlopezroche@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="gmail_quote"><div class="im">On Tue, Jun 1, 2010 at 12:35 AM, Mj Mendoza IV <span dir="ltr"><<a href="mailto:mjmendoza@konsolscript.org" target="_blank">mjmendoza@konsolscript.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">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?<br>
<span></span></div></div></blockquote></div><div><br>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.<br>
<br>[1] <a href="http://openil.sourceforge.net/" target="_blank">http://openil.sourceforge.net/</a><br>[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).<br>
</div></div>
</blockquote></div><br>