An Urgent Question about displaying images



Hi Everybody
I am writting you from the University of British Columbia, Vancouver,
Canada. We are going to have a demo very very soon and because of that I
have written a GUI which in one part, grabs images through a socket
connection and display them on the screen with a frequency of let's say 5
Hz. Now, we have a problem to show these images in gray-scale.
Currently, I am using the following lines in the callbacks.c, where I
connect a function to the expose-event.

GtkWidget *image;
GdkImage *imagegdk;

memcpy(imagegdk->mem,image_buffer, SIZE);
gtk_image_set(GTK_IMAGE(image),imagegdk,NULL);

where I have created this image as follows:

imagegdk=gdk_image_new(GDK_IMAGE_NORMAL,gdk_visual_get_system(),256,256);
image=gtk_image_new(imagegdk,NULL);
gtk_widget_ref(image);
gtk_object_set_data_full(...);
gtk_widget_ref(image);
gtk_widget_show(image);

But, the thing which happens is that instead of showing the images in
grayscale, it shows them in a strange blue and red and ...color! Now, I
tried setting the GdkVisual type to GDK_VISUAL_GRAYSCALE and again it did
not work. Another thing is that the image flickers!!!

I also tried using gdk_draw_gray_image(...)...The problem with this one is
that it is being called once and then it does not work again!!!!

I am confused and could not find any resources which solves this problem.

Your earliest reply is highly appreciated. Please email your correspondances
to:

puranga@ece.ubc.ca

Thank you
Purang






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