Jane wrote:

> my app needs a logo but i dont want to distribute .png 
> files (app should stay a single executable).
> 
> so i found this: 
> http://wiki.wxwidgets.org/Embedding_PNG_Images
> and used bin2c.c to convert my .png to a C vector like:
> 
> static unsigned char myimage_png[] = {
> 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 
> 0x00, 0x0d, // ...
> };

Others have replied useful hints already, but to add my 2 ct:

This would obviously create an array that consists of the png-encodede 
image data. You would have to load this with the png library to decode 
the image data for FLTK's use. Although this ought to be possible, I 
would only do this for much bigger images, where space saving would be 
valuable.

> the image type is:
> PNG image data, 128 x 128, 8-bit/color RGBA, non-interlaced

How big is the resultant array? A simple check (sizeof) should show you 
that it is (or at least should be) as big as the original png file.

> in my code i load the data like this:
> 
> Fl_RGB_Image* logo;
> logo = new Fl_RGB_Image(l128_png, 128, 128, 4);

This would work, if you have the _decoded_ image, and its size should be 
128x128x4 bytes.

> and i have added a box with:
> logobox->image(logo);
> 
> i also call:
> Fl::visual(FL_RGB);
> fl_register_images();
> 
> before anything is being drawn.

This looks okay (if you use the correct image data).

> however, the image is totally distorted, nothing like my 
> logo looks like.
> 
> i have also tried to load the vector with D=3. it looks 
> different but also totally wrong.
> 
> any ideas?

Yes, see the other posts, or learn how to load a png image from memory 
with libpng.

Or, do it yourself like Ian wrote: Use a small program to load the image 
and write the resultant array out to a file yourself (you know how to do 
this. Hint: bin2c.c)

Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to