https://www.seriss.com/people/erco/fltk/#Fl_PNG_Hex_Dump
Once it's in Fl_PNG_Image, you can assign it to a button or box
On 12/27/23 17:52, Rod Morgan wrote:
I should have mentioned I'm using C++.
On Wednesday, December 27, 2023 at 5:48:14 PM UTC-5 Rod Morgan wrote:
I'm hoping someone has an example of creating an Fl_PNG_Image from PNG images compiled into the .exe file by/with Visual Studio. I use images as backgrounds for Fl_Buttons. My goal is to have the images included/compiled into the .exe file and remove the need to include the individual .png files when using/distributing the application. This is for personal/family use and making it easy on my aging parents is paramount.
Would it be possible to refactor the Matt's FLUID inline
compilation code into a stand-alone like Fl_PNG_Hex_Dump?
Something like:
fltk-image <any_valid_fltk_image> output.h
-- Gonzalo Garramuño ggar...@gmail.com
I liked Greg's approach of converting the png using PNG2HEX...so I tried it. PNG2HEX seems to have worked flawlessly and created the attached file named allon.h. I then created a small FLTK app, included the allon.h file and tried to load it using the Fl_PNG_Image::Fl_PNG_Image(const char * name_png, const unsigned char * buffer, int maxsize) constructor. The source is in source.cpp. The code compiles and links without error, but I don't get the image displayed in the button. Can someone point out my error?
Hmm, png2hex is converting the PNG into raw RGBA bytes,
so you'd want to pass this to Fl_RGB_Image instead of
Fl_PNG_Image.
So try instead:
On 12/30/23 18:33, Greg Ercolano wrote:
I'm pretty sure linux provides a program that does this (just takes
any binary file and converts it to C/C++ parseable source code bytes
in a static char array), though I can't think what it is offhand..
Ah, here we go:
xxd -i your.png > allon.h
..that should work for then loading into Fl_PNG_Image's
constructor.