From: Michael Bode <m.g.bode@web.de>
Subject: Re: [newbie] Load a image file into a GTKimage
Date: Thu, 11 Jan 2007 19:40:45 +0100
Date: 2007-01-11T19:40:45+01:00 [thread overview]
Message-ID: <eo60bk$t8k$1@online.de> (raw)
In-Reply-To: 45a63894$0$291$426a74cc@news.free.fr
Rangdalf <rangdalf@hotmail.com> writes:
> I have to display an image in my gtk form. So I have added an gtkimage
> but I want to know of to display a file in it.
The simplest thing, if this is a static image (e.g. company logo or
something) and you use glade, would be to set the image file name in
glade.
Otherwise you can use Gtk.Image.Set:
procedure Set
(Image : access Gtk_Image_Record;
File : String);
procedure Set
(Image : access Gtk_Image_Record;
Pixbuf : Gdk.Pixbuf.Gdk_Pixbuf);
procedure Set
(Image : access Gtk_Image_Record;
Stock_Id : String;
Size : Gtk.Enums.Gtk_Icon_Size);
If you have some small icons that you want to directly include in your
code so you don't have to keep track of icon files you could use the
Ada version of .xpm images. Use the 2nd form of Set above to display
the icon:
with Gdk.Pixbuf;
package Icons is
procedure Init;
LED_Green : Gdk.Pixbuf.Gdk_Pixbuf;
end Icons;
with Gtkada.Types; use Gtkada.Types;
package body Icons is
LED_Green_XPM : Chars_Ptr_Array :=
"31 12 9 1" +
" c #286028" +
". c #227722" +
"+ c #1D8D1D" +
"@ c #17A417" +
"# c #11BB11" +
"$ c #0CD10C" +
"% c #00FF00" +
"& c #2E492E" +
"* c #333333" +
" .++@@@@@###############@@@@@+" +
" .+@@###$$$$$$$$$$$$$$$$$$$###@" +
".+@#$$%%%%%%%%%%%%%%%%%%%%%%%$$" +
".+@#$$%%%%%%%%%%%%%%%%%%%%%%%$$" +
" .+@@###$$$$$$$$$$$$$$$$$$$###@" +
" .++@@@@#################@@@@+" +
"& ..+++++@@@@@@@@@@@@@@@+++++." +
"*&& ...+++++++++++++++++... " +
"***&&& ............. &&" +
"******&&&& &&&&**" +
"***********&&&&&&&&&&&&&*******" +
"*******************************";
procedure Init
is
begin
LED_Green := Gdk.Pixbuf.Gdk_New_From_Xpm_Data (LED_Green_XPM);
end Init;
end Icons;
--
Michael Bode
next prev parent reply other threads:[~2007-01-11 18:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-11 13:15 [newbie] Load a image file into a GTKimage Rangdalf
2007-01-11 15:50 ` Markus E Leypold
2007-01-11 18:40 ` Michael Bode [this message]
2007-01-12 10:24 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox