drawing_area and draw_rgb_image



Hi,
	I am a beginner to all of this and have just set up
gdk,gtk,glib etc. What I would like to do is display some raw data
(which is a satellite image that is 16bit data, no headers) in a
window that is scrollable (I would like eventually to add some
functionality like displaying the value of the data under the cursor
etc but that may take time). I have looked at some examples in
gtk/examples and in the testgtk.c routines. I tried to combine two of
them - a scrollable window that had tables and a test of rgb
display. I have managed to get something up - but the data I display
is lost if I scroll at all and becomes blank (well grey) whereas when
I use the table example the tables scroll fine and come back into
view. Here is my code (well the gtk part):


void
new_testrgb_window (void)
{
  static GtkWidget *window;
  GtkWidget *scrolled_window;
  GtkWidget *table;
  GtkWidget *button;
  char buffer[32];
  int i, j;
  GtkWidget *vbox;
  GtkWidget *drawing_area;
  
  window = gtk_dialog_new ();
  
  gtk_signal_connect (GTK_OBJECT (window), "destroy",
		      GTK_SIGNAL_FUNC(gtk_widget_destroyed),
		      &window);
  
  gtk_window_set_title (GTK_WINDOW (window), "dialog");
  gtk_container_set_border_width (GTK_CONTAINER (window), 0);
  
  
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), 
		      scrolled_window, TRUE, TRUE, 0);
  gtk_widget_show (scrolled_window);
  

/*   HERE WAS THE TABLE STUFF THAT WORKS */
/*   table = gtk_table_new (20, 20, FALSE); */
/*   gtk_table_set_row_spacings (GTK_TABLE (table), 10); */
/*   gtk_table_set_col_spacings (GTK_TABLE (table), 10); */
/*   gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW
(scrolled_window), table); */
/*   gtk_container_set_focus_hadjustment (GTK_CONTAINER (table), */
/* 				       gtk_scrolled_window_get_hadjustment
(GTK_SCROLLED_WINDOW (scrolled_window))); */
/*   gtk_container_set_focus_vadjustment (GTK_CONTAINER (table), */
/* 				       gtk_scrolled_window_get_vadjustment
(GTK_SCROLLED_WINDOW (scrolled_window))); */
/*   gtk_widget_show (table); */
  
/*   for (i = 0; i < 20; i++) */
/*     for (j = 0; j < 20; j++) */
/*       { */
/* 	sprintf (buffer, "button (%d,%d)\n", i, j); */
/* 	button = gtk_toggle_button_new_with_label (buffer); */
/* 	gtk_table_attach_defaults (GTK_TABLE (table), button, */
/* 				   i, i+1, j, j+1); */
/* 	gtk_widget_show (button); */
/*       } */
  
  
  button = gtk_button_new_with_label ("close");
  gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
			     GTK_SIGNAL_FUNC(gtk_widget_destroy),
			     GTK_OBJECT (window));
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->action_area), 
		      button, TRUE, TRUE, 0);
  gtk_widget_grab_default (button);
  gtk_widget_show (button);
  
  gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
  
  /* TRY AND ADD DRAWING AREA */  
  drawing_area = gtk_drawing_area_new ();
  
  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW
(scrolled_window), drawing_area); 
  
  gtk_widget_set_usize (drawing_area, WIDTH, HEIGHT);
  
  gtk_widget_show (drawing_area);
  gtk_widget_show (window);

::::::>>>>>

  This then calls a subroutine which does the following on an array
that has been read in called colorchardata


  gdk_draw_rgb_image (drawing_area->window,
		      drawing_area->style->white_gc,
		      0, 0, WIDTH, HEIGHT, GDK_RGB_DITHER_MAX,
		      colorchardata, WIDTH * 3);





any help much appreciated


andy

-- 

                                 '''''           
                                 (@ @)           
+--------------------------oOO----(_)----------------------------------+
| From Andy Standley         email       andy.standley@bris.ac.uk       |
| Centre for Remote Sensing, UNIVERSITY OF BRISTOL,                     |
| UNIVERSITY ROAD, BRISTOL BS8 1SS                                      |
| TEL 01179 288300 FAX 01179 287878 TELEX 445938                        |
| www site : http://www.ggy.bris.ac.uk/                                 |
|                                                                       |
+-----------------------------------------oOO---------------------------+
                                |__|__|           
                                 || ||         
                                ooO Ooo




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