Re: Use a .png file



On 12/7/05, Bob Caryl <bob fis-cal com> wrote:
> Your original question was:
>
> "How can I include a .png or .bmp image in my source code?"
>
> All the answers I have seen so far show you how to display an image from a file at run time.  None of these show how to include the image in your source code.
>
> The following code displays an image that is compiled as data into the executable itself:
>
> Glib::RefPtr<Gdk::Pixbuf> fis_icon = Gdk::Pixbuf::create_from_inline(-1,fisicon_inline,FALSE);
>
> fis_icon is a data structure that is produced by a gnome command line utility called "gdk_pixbuf_csource."  You can use the "man" command to find out about the calling syntax and output options for this utility.  Then you merely take the file it produces and include it in your source code and the image data is compiled into your application.
>

Wow! That is a cool solution. For me, I open up the image in gimp,
save it out as an XPM, then include the image as source code: #include
"image.xpm". Then I do

Glib::RefPtr<Gdk::Pixbuf> image = Gdk::Pixbuf::create_from_xpm_data(
image_xpm );

So is the gdk_pixbuf_csource function more efficient than xpm
conversion? Also, is it only in gnome?

> Bob
>
> Kathrin Hauptvogel wrote:
>
> >Good morning
> >
> >How can I include a .png or .bmp image in my source code?
> >
> >#include <gtkmm.h>
> >using namespace Gtk;
> >
> >int main(int argc, char *argv[])
> >{
> >  Main kit(argc, argv);
> >
> >  Window window;
> >  Main::run(window);
> >
> >  return 0;
> >}
> >
> >
> >Kathrin Hauptvogel
> >
> >_______________________________________________
> >gtkmm-list mailing list
> >gtkmm-list gnome org
> >http://mail.gnome.org/mailman/listinfo/gtkmm-list
> >
> >
> >
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>


--
R. Douglas Barbieri
doug dooglio net



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