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



On Thu, 29 Apr 1999, Havoc Pennington wrote:

> 
> On Thu, 29 Apr 1999, Geoff Finger wrote:
> > 
> > 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 =)
> > 
> 
> Wild guess: you need to call gdk_rgb_init() and/or you need to 
> push the rgb visual and colormap when you create your drawing area.
> 
> If you do those things, never mind. :-)

No, i hadn't done those things, thanks. However upon adding that bit in, i
stopped getting errors, and started getting a blank box where an image
should have been.

For anyone who has the time to look it it, here's a simplified version.
It's intended to be an all grey image. I'm not sure if the error is in the
code, or in the way i'm creating the image.

thanks again



struct Pixels
{
  guchar * pixel;
  unsigned int length;
  unsigned short h,w;
};

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

  Pixels pixels;
  gint startx=0;
  gint starty=0;
  gint height=256;
  gint width=256;
  
  (pixels.pixel) = 
    new guchar[width*height*3];
  cout<<"Starting load 30.1"<<endl; 
  for (int i=0;i<width*height*3;i++)
    {
      pixels.pixel[i]=0xc0;
    }
  
  gdk_draw_rgb_image(widget->window,
		     widget->style->white_gc,
		     startx,starty,
		     width,height,
		     GDK_RGB_DITHER_NONE,
		     pixels.pixel,
		     width*3);
return TRUE;
}


main(int argc, char* argv[])
{
  GtkWidget *window;
  GtkWidget *close_up;
  GtkWidget *hbox2;

  gtk_init(&argc, &argv);
  gdk_rgb_set_verbose(TRUE);
  gdk_rgb_init();

  gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
  gtk_widget_set_default_visual(gdk_rgb_get_visual());
  window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_policy(GTK_WINDOW(window),FALSE,FALSE,TRUE);
  hbox2=gtk_hbox_new(FALSE,10);
  gtk_container_add (GTK_CONTAINER(window),hbox2);
  /*connect destroy function*/
gtk_signal_connect(GTK_OBJECT(window),"destroy",GTK_SIGNAL_FUNC(quit),NULL);
  /*connect delete function*/
  gtk_signal_connect(GTK_OBJECT(window),"delete_event",
		     GTK_SIGNAL_FUNC(delete_event),NULL);
  gtk_container_border_width(GTK_CONTAINER(window),10);
  close_up=gtk_drawing_area_new();
  gtk_drawing_area_size(GTK_DRAWING_AREA(close_up),256,256);
  gtk_widget_set_usize(close_up, 256, 256);
  gtk_box_pack_start(GTK_BOX(hbox2),close_up,TRUE,TRUE,0);
  gtk_widget_show(close_up);
  gtk_widget_show(hbox2);
  gtk_widget_show(window);
  gtk_signal_connect(GTK_OBJECT(close_up),"configure_event",
		     (GtkSignalFunc)configure_close_event,NULL);
  gtk_main();
  return 0;
}




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