Re: How to store Gdk::Pixbuf pixels into std::string objects



Am 2015-02-23 21:40, schrieb Glus Xof:
Hi guys,

Before anything, I admit that probably my question is not an specifically Gtkmm question... but nevertheless I think you may know how Gdk::Pixbuf is
done...

Having the following,

Glib::RefPtr<Gdk::Pixbuf> ref_orig = Gdk::Pixbuf::create_from_file
("./file.png");

I'm trying to temporary store (because I need so) the image data into a
std::string object. It seems that get_pixels() could solve the problem,
getting a pointer of type guint8.

Seems that gdkmm is not up-to-date here.
gdk uses a guchar*. But this shouldn't be a problem.

So, I wrote as follows,

std::string image_pixels (reinterpret_cast<const char
*>(ref_orig->get_pixels()), ref_orig->get_rowstride());

I think this does not what you expect.

https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#gdk-pixbuf-get-rowstride

See also the part below the description headline.

Maybe you should use gsize Gdk::Pixbuf::get_byte_length()
because https://developer.gnome.org/gdk-pixbuf/stable/gdk-pixbuf-The-GdkPixbuf-Structure.html#gdk-pixbuf-get-pixels-with-length is missing.

I hope it will help you.

But think about the std::string. Big ? ;-)



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