Re: [gtk-list] how to show GdkImlibImage?



>         I use "Gdk_Imlib" library creating a GdkImlibImage object. As a test, I want to show
> this image as background of a window widget. 
>         
>         The sample codes are as follow, but it can not reach my target !!!
> 
> #include <gtk/gtk.h>
> #include <gdk/gdk.h>
> #include <gdk_imlib.h>
> 
> int main(int argc, char* argv[])
> {
>         Gtkwidget * window;
>         GdkImlibImage * image;
>         GdkPixmap * pixmap;
> 
>         gtk_init(&argc,&argv);
>         gdk_imlib_init();

You forgot to set the visual and colormap.

  gtk_widget_push_visual(gdk_imlib_get_visual());
  gtk_widget_push_colormap(gdk_imlib_get_colormap());

>         
>         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>         gtk_widget_realize(window);
> 
> /************************************************************************************/
>                                                                                                                           
>         image = gdk_imlib_load_image("linuxGirl.xpm");// as a sample xpm file   
>         pixmap = gdk_imlib_copy_image(image);

This is wrong, you first have to render the image. From the gdk_imlib
programmers guide:

  GdkPixmap *pixmap, *mask;

  gdk_imlib_load_image("linuxGirl.xpm");
  gdk_imlib_render(image, 100, 100); /* render at 100x100 */
  pixmap = gdk_imlib_move_image(image); 
  mask = gdk_imlib_move_mask(image);
  gdk_window_set_back_pixmap(window->window, pixmap, 0);
  gdk_window_shape_combine_mask(window->window, mask, 0, 0);
         
> 
> /************************************************************************************/
> 
>         gdk_window_set_back_pixmap(window->window,pixmap,0);
>         gtk_widget_set_app_paintable(window,TRUE);
>         gdk_window_show(window->window);
>         gtk_widget_show(window);
>         
>         gtk_mian();
>         return 0;
> }
> 
> As my personal opinion, I think the problem located in the scale which was encapsulated by "/*******/".
> 
> It was because that when I use other method to create pixmap it worked well.
> 
> So my question is how can I get pixmap from GdkImlibImage?

You should get the Imlib programmers guide at
http://www.labs.redhat.com/imlib/ .


Erik
-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2785859  Fax: +31-15-2781843  Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/



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