[gtkmm] Gdk::Pixbuf: get_pixels(): Const corrections.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Gdk::Pixbuf: get_pixels(): Const corrections.
- Date: Fri, 17 Mar 2017 07:24:02 +0000 (UTC)
commit 422c202a31740d2d52c045e97975b4b7a9f15be4
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Mar 17 08:19:52 2017 +0100
Gdk::Pixbuf: get_pixels(): Const corrections.
gdk/src/pixbuf.ccg | 5 +++++
gdk/src/pixbuf.hg | 14 ++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/gdk/src/pixbuf.ccg b/gdk/src/pixbuf.ccg
index 64dd6b7..7895430 100644
--- a/gdk/src/pixbuf.ccg
+++ b/gdk/src/pixbuf.ccg
@@ -166,4 +166,9 @@ std::vector<PixbufFormat> Pixbuf::get_formats()
return Glib::SListHandler<PixbufFormat, PixbufFormatTraits>::slist_to_vector(gdk_pixbuf_get_formats(),
Glib::OWNERSHIP_SHALLOW);
}
+const guint8* Pixbuf::get_pixels(guint& length) const {
+ length = get_byte_length();
+ return gdk_pixbuf_read_pixels(const_cast<GdkPixbuf*>(gobj()));
+}
+
} // namespace Gdk
diff --git a/gdk/src/pixbuf.hg b/gdk/src/pixbuf.hg
index 5b2a04a..d67663d 100644
--- a/gdk/src/pixbuf.hg
+++ b/gdk/src/pixbuf.hg
@@ -218,8 +218,18 @@ public:
_WRAP_METHOD(int get_n_channels() const, gdk_pixbuf_get_n_channels)
_WRAP_METHOD(bool get_has_alpha() const, gdk_pixbuf_get_has_alpha)
_WRAP_METHOD(int get_bits_per_sample() const, gdk_pixbuf_get_bits_per_sample)
- _WRAP_METHOD(guint8* get_pixels() const, gdk_pixbuf_get_pixels)
- _WRAP_METHOD(guint8* get_pixels(guint& length) const, gdk_pixbuf_get_pixels_with_length)
+
+ // Note that the const version uses gdk_pixbuf_read_pixels, not gdk_pixbuf_get_pixels(),
+ // because gdk_pixbuf_get_pixels() is documented as sometimes copying data internally
+ // so the caller can make changes, but a const version wouldn't ever do that.
+ _WRAP_METHOD(guint8* get_pixels(), gdk_pixbuf_get_pixels)
+ _WRAP_METHOD(const guint8* get_pixels() const, gdk_pixbuf_read_pixels)
+
+ _WRAP_METHOD(guint8* get_pixels(guint& length), gdk_pixbuf_get_pixels_with_length)
+
+ // We hand-code this because there is no gdk_pixbuf_read_pixels_with_length().
+ const guint8* get_pixels(guint& length) const;
+
_WRAP_METHOD(int get_width() const, gdk_pixbuf_get_width)
_WRAP_METHOD(int get_height() const, gdk_pixbuf_get_height)
_WRAP_METHOD(int get_rowstride() const, gdk_pixbuf_get_rowstride)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]