gdk-pix(buf|map) problem



I have a function that loads an image then draws it to a pixmap and a
bitmap, which are returned.
The problem is that if I make a pixmap with a depth more than 1, it gives me
BadValue and BadMatch errors.
The essence of the function is :
void
gum_load_image (gchar *filename,
                              GdkPixmap **pmap,
                              GdkPixmap **bmap)
{
  GdkPixmap *p, *b;
  GdkPixbuf *pixbuf;

  pixbuf = gdk_pixbuf_new_from_file (filename);

  p = gdk_pixmap_new (NULL, 20, 20, 8);
  b = gdk_pixmap_new (NULL, 20, 20, 1);

  /* Render the pixmap */
  gdk_pixbuf_render_to_drawable (pixbuf, p,
    gdk_gc_new (p),
    0, 0,
    0, 0,
    20, 20,
    GDK_RGB_DITHER_NORMAL,
    0, 0);

  /* Render the mask */
  gdk_pixbuf_render_threshold_alpha (pixbuf, b,
    0, 0,
    0, 0,
    20, 20,
    128);

    *pmap = p;
    *bmap = b;
}

The whole code can be found at
http://www.webtribe.net/i/iain/Gum-0.2.3.tar.gz
The above function is called 3 times, and runs without a hitch, then when
the clist is shown it gives the Bad* errors. Even if the values that are put
into pmap and bmap are not used the errors still occur, which is why I
suspect it's memory corruption, but I've spent the best part of a week
trying to find it, and can't.
It works fine if I don't call the function, and it works fine if I call the
function and it's setup to use imlib instead of gdk-pixbuf (not shown in the
code for clarity).

Can anyone spot what I'm doing wrong?
iain



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