[cairo] cairo+DevIL ?
John Ellson
john.ellson at comcast.net
Sat Aug 18 05:06:54 PDT 2007
Vladimir Vukicevic wrote:
> John Ellson wrote:
>> In a January 2007 posting
>>
>> <http://lists.cairographics.org/archives/cairo/2007-January/009198.html>
>> Vlad suggested that DevIL
>> <http://openil.sourceforge.net/>
>> would make a good backend for rendering other bitmap formats (gif,
>> jpeg, tga, ...) from cairo.
>>
>> Is this still the best-practice recommendation? Is there any sample
>> code out there?
>>
>> I've made an initial attempt to bind the two together. The problem
>> I'm having at the moment
>> is that the in-memory data formats seem to be incompatible:
>> CAIRO_FORMAT_ARGB32 v. IL_RGBA
>>
>> Do I really have to byte-twiddle the image data just to transfer
>> between these two fine libraries?
>
> I'm not sure if there is a single best-practice recommendation; I've
> certainly had good experience using DevIL in the past, though I have
> never used it with cairo. It's interesting that DevIL only provides
> IL_RGBA and IL_BGRA; the documentation annoyingly states that these
> formats are "self explanatory", which they are not. Maybe IL_BGRA
> happens to be compatible, if they're talking about byte order?
>
> - Vlad
>
Both IL_BGRA and IL_RGBA result in black images. The size of my image
is right. I'm attempting
to transfer the image data using:
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,120,60);
...
rc = ilTexImage(
cairo_image_surface_get_width(surface), // Width
cairo_image_surface_get_height(surface),// Height
1, // Depth
4, // Bpp
IL_BGRA, // Format
IL_UNSIGNED_BYTE, // Type
cairo_image_surface_get_data(surface) // Data
);
I'm just assuming my problem is byte-order, the DevIL documentation
isn't very clear, I'm going to have to dig deeper
into the code.
John
More information about the cairo
mailing list