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),
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:

Murray Cumming
murrayc murrayc com

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