comp.lang.ada
 help / color / mirror / Atom feed
* [newbie] Load a image file into a GTKimage
@ 2007-01-11 13:15 Rangdalf
  2007-01-11 15:50 ` Markus E Leypold
  2007-01-11 18:40 ` Michael Bode
  0 siblings, 2 replies; 4+ messages in thread
From: Rangdalf @ 2007-01-11 13:15 UTC (permalink / raw)


Hi,

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.

Thanks in advance.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [newbie] Load a image file into a GTKimage
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Markus E Leypold @ 2007-01-11 15:50 UTC (permalink / raw)




Rangdalf <rangdalf@hotmail.com> writes:

> Hi,
>
> 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.
>
> Thanks in advance.


   procedure ... is

      Im: Gtk_Image;

   begin

      Gtk_New(Im, "splashscreen.png");

      ...
   end;


Like this?

Regards -- Markus



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [newbie] Load a image file into a GTKimage
  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
  2007-01-12 10:24   ` Dmitry A. Kazakov
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Bode @ 2007-01-11 18:40 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [newbie] Load a image file into a GTKimage
  2007-01-11 18:40 ` Michael Bode
@ 2007-01-12 10:24   ` Dmitry A. Kazakov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry A. Kazakov @ 2007-01-12 10:24 UTC (permalink / raw)


On Thu, 11 Jan 2007 19:40:45 +0100, Michael Bode wrote:

[...]
> 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" +
[...]

You could also xpm2gtkada utility to generate Gtk_Image-producing Ada code
directly from an XPM image. See

http://www.dmitry-kazakov.de/ada/gtkada_contributions.htm#3

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-01-12 10:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2007-01-12 10:24   ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox