Encode image in the file?



Hi everyone

I have this UI that displays an image using

add(*manage(new Gtk::Image("image.png")));

But the app pulls it from the hard drive at each lauch, and if it's not there it's broken, etc.

I tried that:


    Glib::RefPtr<Gdk::Pixbuf> pic = Gdk::Pixbuf::create_from_file("image.png");
    Gtk::Image* img = Gtk::manage(new Gtk::Image(pic));
    add(*img);

But it's even worse, if the image is missing at run time, it coredumps ; How can I encode image.png so that I can ship it in the code, so the app dont't have to find/read an image file?

In GIMP I can save an image as "C source code" or "C header file" but not C++... I tried too.

Cheers -Phil


-- 
Philippe "xaccrocheur" Coatmeur
http://bitbucket.org/xaccrocheur / https://github.com/xaccrocheur
http://opensimo.org/play/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]