strange trouble in displaying a 8bit monochromy grey scale image



I need to display a 8 bit monochromy image with size of 2048x2048 pixels, all
the image data are already loaded into memory,  and out of which I created a
24 bit RGB buffer for the GdkPixbuf (please see code below)

Well, the result is: The GtkImage widget was expanded to size of 2048x2048
pixels, THREE exactly same images tile in a row in the top of the GtkImage
widget, each with size shrinked to 684x684 pixels, and all the lower 2/3
space is left blank.(see the attached image below)

Can anyone please look at my code and give me some suggestion on this
problem? I have been debugging is problem for almost one week time! Or I
wonder if there is any other alternative mean to display a grey scale
monochromy image.

Any help is highly appriciated!



following is my code:

......
char* pDisplayBuf = malloc(sizeX*sizeY*3);
for(i=0;i<sizeX*sizeY;i++)
	{
	//create a gray scale img in the display buffer
		pDisplayBuf[i+1]=pDisplayBuf[i+1]=pDisplayBuf[i+2] = pixel_value;
	}
	
//create a GdkPixbuf
	GdkPixbuf* pb = gdk_pixbuf_new_from_data( pDisplayBuf, // data
		GDK_COLORSPACE_RGB,	// COLORSPACE
		FALSE,			// has_alpha,
		8,			// int bits_per_sample,
          	sizeX,			// int width,
           	sizeY,			// int height,
              	sizeX*3,// sizeX;  	// int rowstride,
              	NULL,			// GdkPixbufDestroyNotify destroy_fn,
            	NULL);			// gpointer destroy_fn_data);
		
//display img
	GtkWidget* img = lookup_widget(MainWnd, "image1");
	gtk_image_set_from_pixbuf(GTK_IMAGE(img),//	GtkImage *image,
        	pb);				 //     GdkPixbuf *pixbuf
		
//free the GdkPixbuf object
	g_object_unref(pb);
	g_object_unref(pb2);

...... http://www.nabble.com/user-images/2968.png 
--
View this message in context: http://www.nabble.com/strange-trouble-in-displaying-a-8bit-monochromy-grey-scale-image-t1722069.html#a4677819
Sent from the Gtk+ - Dev - General forum at Nabble.com.




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