Re: How to display an image array?



I did this exact thing using cairomm, which gives the added benefit of then being able to use cairo to add any additional annotation, etc.

See http://www.mail-archive.com/gtkmm-list gnome org/msg11199.html

If you need additional help, let me know.

--Chris Wilson

On Mon, Sep 29, 2008 at 1:32 PM, John Hobbs <john velvetcache org> wrote:
Send to list.
---------- Forwarded message ----------
From: simba simba <simba buffalo gmail com>
Date: Mon, Sep 29, 2008 at 2:24 PM
Subject: Re: How to display an image array?
To: John Hobbs <john velvetcache org>


Thanks.

I tried to convert gray image to RGB first and then display it. it works although not convenient.

sim


On Mon, Sep 29, 2008 at 10:57 AM, John Hobbs <john velvetcache org> wrote:
I've never used any gray scale images before, but I think the colorspace is the issue. In the gdk-pixbuf docs it says: "This enumeration defines the color spaces that are supported by the gdk-pixbuf library. Currently only RGB is supported." [1]

I realize it is far from optimal, but can you just convert up to rgb?  Your other choice is Cairo maybe, but that doesn't look very likely either, same issue. [2]

Don't know what to say except I'd probably just convert up.  Anyone else have ideas?[1] http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-gdk-pixbuf.html#GdkColorspace
[2] http://www.cairographics.org/manual/cairo-Image-Surfaces.html#cairo-format-t


On Sat, Sep 27, 2008 at 11:22 PM, simba simba <simba buffalo gmail com> wrote:
Thanks John:

I am using Gdk::Pixbuf::create_from_data(), it seems good except for some one channel gray images.

I have an array guint8 * data corresponds to a image, each pixel has 8-bits (1 BYTE), when I use
create_from_data(), the show image is weired. it is duplicated 3 times.


Gdk::Pixbuf::create_from_data(
     (guint8*) data,
     Gdk::COLORSPACE_RGB,
     false,
     depth,
     width,
     height,
     width);

Any sugguestion for  this?

sim


On Fri, Sep 26, 2008 at 4:10 PM, John Hobbs <john velvetcache org> wrote:
Don't know if this will help, but here is a snippet I use to draw straight onto the Gdk::Window  (screen is a Gtk::Image in this case)

<snip>
screen.get_window()->draw_rgb_image(
     screen.get_style()->get_bg_gc(Gtk::STATE_NORMAL),
     0,
     0,
     width,
     height,
     Gdk::RGB_DITHER_NONE,
     (const guchar*) data,
     width*3
);
</snip>

And here's one I use with pixbuf...

<snip>
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create_from_data(
     (guint8*) data,
     Gdk::COLORSPACE_RGB,
     false,
     depth,
     width,
     height,
     width*3
);
</snip>

Not sure if they are the "right" way to do it, but they work for me.

- John Hobbs

john velvetcache org

On Fri, Sep 26, 2008 at 2:57 PM, simba simba <simba buffalo gmail com> wrote:
Hi dear all:

Now I have a image array, char * data. I know this array's length( image's width and height) and array's format( RGB 32bits for a pixel or Grayscale leve 8bits for a pixel).

My question is how can I display this image array by using gtkmm?

I have tried using Gtk::Pixbuf  pixbuf.create_from_data().

But it is not good for me. Is there any example codes?

Thanks a lot!!

simba

_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list



_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list




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