[cairo] Using gimp c file image
gurnett at telia.com
gurnett at telia.com
Thu Dec 17 04:52:05 PST 2009
Thanks.
I am looking at the second option to use i conjunction with a resource. Using
resources seems like the best way instead of converting to gimp c images.
Tack så mycket (Thanks alot)
Michael
>----Ursprungligt meddelande----
>Från: dov.grobgeld at gmail.com
>Datum: 2009-12-17 13:37
>Till: "gurnett at telia.com"<gurnett at telia.com>
>Kopia: <cairo at cairographics.org>
>Ärende: Re: [cairo] Using gimp c file image
>
>You can use gdk_pixbuf and in your build system do:
>
>gdk-pixbuf-csource --name=foo_inline foo.png > foo.i
>
>And in your c-source do:
>
>#include "foo.i"
>
>:
>
>GdkPixbuf* foo_pixbuf = gdk_pixbuf_new_from_inline(sizeof
(foo_inline),
> foo_inline,
> FALSE,
> &error);
>
>You can then create a image surface through:
>
> cairo_surface_t *surface = cairo_image_surface_create_for_data
>(gdk_pixbuf_get_pixels(foo_pixbuf),
>
>gdk_pixbuf_get_has_alpha(foo_pixbuf) ? CAIRO_FORMAT_ARGB32 :
>CAIRO_FORMAT_FORMAT_RGB24
> gdk_pixbuf_get_width(foo_pixbuf),
> gdk_pixbuf_get_height(foo_pixbuf),
> gdk_pixbuf_get_rowstride
(foo_pixbuf));
> gdk_pixbuf_unref(foo_pixbuf);
>
>
>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.)
>
>Another option if cairo has been compiled with PNG support, is to do:
>
>cairo_surface_t * cairo_image_surface_create_from_png_stream
> (cairo_read_func_t read_func,
> void *closure);
>
>You will then have to write a read_func instance that will provide data from
>your baked png file.
>
>Hope this helps.
>
>Lycka till!
>Dov
>
>On Thu, Dec 17, 2009 at 11:05, gurnett at telia.com <gurnett at telia.com> wrote:
>
>> I have an app that has a lot of png files. I've asked previously if it was
>> possible to use embedded png images with cairo, but this did not seem
>> possible.
>> As I really want to bake all this images into the exe I was wondering if it
>> is
>> possible to use the gimp c file image format and use that instead of
>>
>> image=cairo_image_surface_create_from_png("image.png");
>>
>> Thanks
>>
>> Michael
>> --
>> cairo mailing list
>> cairo at cairographics.org
>> http://lists.cairographics.org/mailman/listinfo/cairo>>
>
More information about the cairo
mailing list