Re: Display grayscale image
- From: "Jim George" <jimgeorge gmail com>
- To: m brambilla polimi it
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Display grayscale image
- Date: Fri, 31 Aug 2007 00:08:38 -0600
On 8/30/07, Marco Brambilla <m brambilla polimi it> wrote:
Firs of all I'm a newbye both to GTK and to this mailing list, so I apologize for the triviality of the
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)
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
the a RGB triplet needed by gtk_pixbuf_new_from_data ?
Any advice is very welcome.
Thanks in advance to everybody.
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.
] [Thread Prev