GdkPixbuf query



Hi,
  I am using the gdk-pixbuf library for loading & displaying images. I'm
having a few problems however. I've got a GtkDrawingArea and when the
expose_event occurs the callback tries to load the image and displays it
on the GtkDrawingArea. The image loads fine and apparently the image is
rendered to the widget. But I get a  failed assertion:

** CRITICAL **: file gdk-pixbuf-render.c:
line 209 (gdk_pixbuf_render_to_drawable):
assertion `src_x >= 0 && src_x + width <= pixbuf->width' failed.

and also no image appears on the drawing area.

Could somebody please help out. Below is the code I'm using for the
expose_event callback:

Is it valid to pass the GtkDrawingArea as a drwabale to the
gdk_pixbuf_render_to_drawable function?

Finally, are there any websites where I could look at some example code
of loading/displaying images using this library?


  GdkGC *gc;
  static int counter = 1;

  if (counter != 1)
    return FALSE;
  else
    counter++;

  printf("pic:: Trying to load and display the image\n");
  pic = gdk_pixbuf_new_from_file("us.png");

  if (pic == NULL)
    {
      printf("pic:: Error loading image\n");
      exit(0);
    }
  else
    {
      printf("pic:: Image Loaded\n");
      printf("pic:: Width = %d , Height = %d\n",
      gdk_pixbuf_get_width(pic),gdk_pixbuf_get_height(pic));
    }
  gdk_rgb_init();
  w = gtk_widget_get_parent_window(widget);
  if (w != NULL)
    {
      gc = gdk_gc_new(w);
      gdk_pixbuf_render_to_drawable(pic,
        (GdkDrawable*)widget,
        gc,
        1,1,1,1,
        gdk_pixbuf_get_width(pic), gdk_pixbuf_get_height(pic),
        GDK_RGB_DITHER_NONE, 0,0);
      printf("pic:: Rendered image to drawable\n");
    }
  else
    printf("pic:: The GtkDrawingArea window widget is NULL\n");

  return FALSE;
}



--
-------------------------------------------------------------
Rajarshi Guha

email: rajarshi presidency com
web: http:/www.psynet.net/jijog









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