Re: Display grayscale image



On 8/30/07, Marco Brambilla <m brambilla polimi it> wrote:
Hello everybody,

Firs of all I'm a newbye both to GTK and to this mailing list, so I apologize for the triviality of the 
post.
I'm writing a very simple application (language: C) which should grab frames from a ccd camera and show 
them on the screen.
The ccd images are stored as a 1D array of unsigned char, single channel grayscale images.
Looking around inside the API docs, I tried to use something like:

pixbuf = gtk_pixbuf_new_from_data(.....);
image = gtk_image_new_from_pixbuf(pixbuf);

The problem is that this way, the displayed image is messed up, since (for what I understand) 
gtk_pixbuf_new_from_data needs
the three RGB channels.
Is there a easy way of displaying such an image "as is" (single channel) ? Or must I convert it each pixel 
to
the a RGB triplet needed by gtk_pixbuf_new_from_data ?
Any advice is very welcome.

Thanks in advance to everybody.

Marco

You could possibly use gdk_image, but it's easier to use a pixbuf and
just copy the grayscale value thrice into R, G and B. Remember to use
the rowstride, and not the width of the image when creating a pointer
to go from one row to the next.

-Jim



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