Re: dilspay image -- i need help



On Sun, Mar 25, 2007 at 05:05:12AM -0700, bajone wrote:

I am trying to load and display an image(jpg,gif) in a window , but something
is going wrong... I insert a button in a box, and then i add it in window
container... after I chose a file from directory,and i add it into box....
can be image added into box?

Of course it can.

I do it in 2 ways:

Both are good.

image=gtk_image_new_from_file(selected_filename); (and after I cannot
display it, only broken icon apears)

Then selected_filename (the variable) is rubbish -- or the
image you intend to load is rubbish, but you probably
checked that.

pixbuf= gdk_pixbuf_new_from_file (selected_filename, NULL);
image=gtk_image_new_from_pixbuf(pixbuf);

This looks good...

(compilation error when i try to add it into box, can't parse image in
GtkWidget object)

...but this makes no sense.  What is `can't parse image in
GtkWidget object'?

Anyway, you should not get any error messages you don't
understand from compiling Gtk+ code -- it's just a bunch of
normal typedefs, functions and type-casting macros.

I tryed to load image directly into window or popup window but nothing
happens...

Neither does this.  What is `loading image directly into
a window'?

I tryed to load a window into another window but it doesn't help.

Window is a top-level object.  You cannot place a window
into another window (well, except in some special cases
unrelated to this).

Should I draw an image pixel after pixel in drawin area window?

No.  Both gtk_image_new_from_file() and loading it
explicitly to a pixbuf as you outlined them above are the
right methods.

Thanks for any kind of help

(a) Look at the source code of any Gtk+ program that
displays images.  It should be very easy to find some.
For instance the Gtk+ source tarball contains several
image-displaying demos.

(b) Post the code and the errors instead of vague verbal
descriptions.

Yeti

--
http://gwyddion.net/



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