[cairo] [cairomm] inline Images

Carl Worth cworth at cworth.org
Wed Apr 4 17:37:24 PDT 2007

On Wed, 28 Mar 2007 05:30:38 -0700 (PDT), The-Kenny wrote:
> Is there a way to store images (Png) in the sourcecode?

For reference, cairo_image_surface_create_from_png_stream can be used
with an array that contains actual PNG data, (that is, precisely the
contents of a PNG file). This takes a very little bit of effort,
(writing the trivial read function).

Alternately, cairo_image_surface_create_for_data can be used with an
array that contains the un-encoded image content in a supported cairo
format. I think the two previous replies suggested approaches for
generating arrays, but not properly formatted for cairo.

The simplest way to get a properly formatted array is probably to just
write a tiny program that uses cairo_image_surface_create_from_png
with the filename, then uses the following functions:


and a loop to emit a C-syntax array with the data.

I think this is exactly what "The-Kenny" ended up doing, (after some
discussion in IRC). Want to share the final program you came up with
for that conversion?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070404/b10ee08d/attachment.pgp

More information about the cairo mailing list