Re: gtkmm: Pixbuf::get_pixels()



On Thu, 2017-03-16 at 14:34 +0100, Kjell Ahlstedt wrote:
The const usage is wrong in both get_pixels() methods. Should be
  _WRAP_METHOD(guint8* get_pixels(), gdk_pixbuf_get_pixels)
  _WRAP_METHOD(guint8* get_pixels(guint& length),
gdk_pixbuf_get_pixels_with_length)
and perhaps
  _WRAP_METHOD(const guint8* get_pixels() const,
gdk_pixbuf_get_pixels, constversion)
  _WRAP_METHOD(const guint8* get_pixels(guint& length) const,
gdk_pixbuf_get_pixels_with_length, constversion)

The documentation of gdk_pixbuf_get_pixels[_with_length]() says
"This function will cause an implicit copy of the pixbuf data if the
pixbuf was created from read-only data."
I take this to mean that it's alright for the caller to change the
pixel data. (The implicit copy is owned by the GdkPixbuf object. The
caller shall not delete it.) There is also the
gdk_pixbuf_read_pixels() function (not yet wrapped in Gdk::Pixbuf)
which returns a const guint8*. It's perhaps a better choice when you
don't want to change the pixels, because it does not make a copy of
read-only data.

Thanks. I didn't know about that. I've changed it as you suggest:
https://git.gnome.org/browse/gtkmm/commit/?id=422c202a31740d2d52c045e97
975b4b7a9f15be4

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com



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