Re: [gtk-list] Re: Question: Displaying Images (TIM Files)




ok, i'm feeling rather dumb right now.

I took a look at the testrgb.c code, and tried tossing together a test
case. (ok, i just tried pluging it into my code, and when that failed, i
tried making a test case, which also failed =)

/*theres a GtkWidget called close_up*/

  close_up=gtk_drawing_area_new();
  gtk_drawing_area_size(GTK_DRAWING_AREA(close_up),256,256);

  gtk_signal_connect(GTK_OBJECT(close_up),"configure_event",
		     (GtkSignalFunc)configure_close_event,NULL);


/*the function*/

static gint configure_close_event (GtkWidget *widget, GdkEventConfigure
*event)

/*calls*/

LoadTim(widget,timdata,timfile);

/*(timdata and timfile are irrelevant at the momment, they're there for
transfering the tim file once i get gdk_draw working =)*/

/*the function*/

void LoadTim (GtkWidget *drawing_area,Tim tim, istream &file)

/*has in it the following*/

gint startx=0;
gint starty=0;
gint height=256;
gint width=256;

 (tim.image.pixel) = 
   new guchar[width*height*3];
 for (int i=0;i<width*height*3;i++)
   {
     tim.image.pixel[i]=0x80;
   }
 gdk_draw_rgb_image(drawing_area->window,
		    drawing_area->style->white_gc,
		    startx,starty,
		    width,height,
		    GDK_RGB_DITHER_NONE,
		    tim.image.pixel,
		    width*3);

tim.image.pixel is a guchar *

the program gets a seg fault when it tries to run gdk_draw_rgb_image

According to what little gdk docs i could find, it's getting passed all
the right data types. The window is big enough to hold the image. I copied
the format from testrgb.c which compiles and runs fine.

What am i missing? Is there something i don't understand about the RGB
format? As far as i can tell, the above should produce a 256x256 image
of solid grey.

any help or suggestions of where to go look for help would be greatly
appreciated.

thanks





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