gdk bitmap error




I would like to use bitmaps in part of a tapestry chart generator I'm
writing.  Currently I'm using pixmaps throughout, but a significant
part of the program uses plain black/white icons.  Using bitmaps
here would reduce code size and maybe speed it up a bit.

I can't get gdk_bitmap_create_from_data to work.  I've read through
the manuals and tutorials, and as far as I can see I'm using it right,
but whenever I get to a point where one of the bitmaps would be
displayed the process dies and

Gdk-ERROR **: BadMatch (invalid parameter attributes)
  serial 80 error_code 8 request_code 62 minor_code 0

is printed on stderr.

The code included reproduces the problem nicely on both Linux (Debian
2.0 + 2.2.5 kernel) and Solaris 7.  I'm using GTK+/Glib 1.2.3.

The icon should be an elongated right pointing arrow.

I suspect I'm doing something daft, anyone have any ideas?
Thanks in advance.


#include <gtk/gtk.h>

#define icon_width 90
#define icon_height 16
static char icon_bits[] = {
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x03,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
 0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,
 0xff,0xff,0xff,0x7f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
 0x7f,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,
 0x00,0xf0,0xff,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,
 0xff,0xff,0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0x03,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf0,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

main(int argc, char ** argv)
{
  GtkWidget *window, *pixwid;
  GdkPixmap *pixmap;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  pixmap = gdk_bitmap_create_from_data(window->window, icon_bits,
				       icon_width, icon_height);
  pixwid = gtk_pixmap_new(pixmap, NULL);
  gtk_container_set_border_width(GTK_CONTAINER(window), 100);
  gtk_container_add(GTK_CONTAINER(window), pixwid);
  gtk_widget_show(pixwid);
  gtk_widget_show(window);

  gtk_main();
}

-- 
Tony Towers



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