Re: loading a displaying an image in GTK 1.2.



On Tue, Nov 21, 2006 at 04:23:43PM -0500, LWATCDR wrote:
> I am trying to us imlib with GTK.1.2 to load and display a jpeg. I have to
> stick with 1.2 since I am using it in an embedded enviroment and can not
> move to 2.0
> I am not getting any errors when I run my code but also no image.
> 
> Here is the code
> 
> void Display::OpenDisplay(void){
>    //lkyb=this;
> 
>    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
>    gtk_window_set_default_size((GtkWindow*)window,640,240);
>    gtk_widget_show ((GtkWidget *)window);
>    OpenSplash();
>    gdk_flush();
> 
> }
> 
> void Display::OpenSplash(void){
>    GdkPixmap    *p;
>    im=gdk_imlib_load_image("/home/david/images/beach.jpg");
>    gdk_imlib_render(im,640,240);
>    p=gdk_imlib_move_image(im);
>    gdk_draw_pixmap(window->window,window->style->fg_gc[GTK_WIDGET_STATE
> (window)],
>                  p,
>                  640,240,
>                  640,240,
>                  640, 240);
> }
> 
> Any suggestions?

I don't recall Gtk+ 1.2 much so I can't tell whether imlib
is used correctly, but:

You have to draw in "expose-event" handler (and typically
only there).  See the example in GtkDrawingArea
documentation (2.x, but you get the idea) and see also
`writing your own widget from scratch' chapter of the
tutorial, particularly the part concerning drawing.

And remove the gdk_flush().

Yeti


--
Whatever.



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