Re: How to display an image array?



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




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