<div dir="ltr">You can use gdk_pixbuf and in your build system do:<br><br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">gdk-pixbuf-csource --name=foo_inline foo.png &gt; foo.i</span><br style="font-family: courier new,monospace;">
</div><br>And in your c-source do:<br><br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">#include &quot;foo.i&quot;</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">GdkPixbuf* foo_pixbuf = gdk_pixbuf_new_from_inline(sizeof(foo_inline),</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                           foo_inline,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                           FALSE,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                           &amp;error);</span><br></div><br>You can then create a image surface through:<br><br><pre class="programlisting">    cairo_surface_t *surface = cairo_image_surface_create_for_data (gdk_pixbuf_get_pixels(foo_pixbuf),<br>
                                         gdk_pixbuf_get_has_alpha(foo_pixbuf) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_FORMAT_RGB24<br>                                         gdk_pixbuf_get_width(foo_pixbuf),<br>                                         gdk_pixbuf_get_height(foo_pixbuf),<br>
                                         gdk_pixbuf_get_rowstride(foo_pixbuf));<br>    gdk_pixbuf_unref(foo_pixbuf);<br></pre><br>There is one problem though, which is that cairo and gdk pixbuf does not agree on the order of R,G,B and alpha. So you will have to swap the data before you do this. (Instead of gdk pixbuf you can use any image library, e.g. libpng, opencv, FreeImage, etc.)<br>
<br>Another option if cairo has been compiled with PNG support, is to do:<br><br style="font-family: courier new,monospace;"><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">cairo_surface_t *   cairo_image_surface_create_from_png_stream</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                                                                         (cairo_read_func_t read_func,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                                                                           void *closure);</span><br style="font-family: courier new,monospace;">
<br></div>You will then have to write a read_func instance that will provide data from your baked png file.<br style="font-family: courier new,monospace;"><div><br>Hope this helps.<br><br>Lycka till!<br>Dov<br><br><div class="gmail_quote">
On Thu, Dec 17, 2009 at 11:05, <a href="mailto:gurnett@telia.com">gurnett@telia.com</a> <span dir="ltr">&lt;<a href="mailto:gurnett@telia.com">gurnett@telia.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have an app that has a lot of png files. I&#39;ve asked previously if it was<br>
possible to use embedded png images with cairo, but this did not seem possible.<br>
As I really want to bake all this images into the exe I was wondering if it is<br>
possible to use the gimp c file image format and use that instead of<br>
<br>
image=cairo_image_surface_create_from_png(&quot;image.png&quot;);<br>
<br>
Thanks<br>
<br>
Michael<br>
<font color="#888888">--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</font></blockquote></div><br></div></div>