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




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

Did you mean ref_orig->get_rowstride() * ref_orig->get_height() ?

Glib::RefPtr<Gdk::Pixbuf> ref_dest = Gdk::Pixbuf::create_from_data (
reinterpret_cast<const guint8*>(image_pixels.c_str()),
Gdk::COLORSPACE_RGB, ref_orig->get_has_alpha(),
ref_orig->get_bits_per_sample(), ....);

std::string::c_str() copies the data in a new null terminated buffer, so this cannot work if your image contains null bytes. Maybe std::string::raw() will do the trick, but I advise to investigate another way of storing your pixels.

yann



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