[gtkmm] add Gdk::Pixbuf::create_for_stream() and create_for_stream_at_scale()



commit e1b9cfb18a794021b8a1ec34dbf968012310e4f5
Author: Jonathon Jongsma <jonathon quotidian org>
Date:   Tue Jun 30 00:34:45 2009 -0500

    add Gdk::Pixbuf::create_for_stream() and create_for_stream_at_scale()

 ChangeLog               |    9 +++++++++
 configure.ac            |    1 +
 gdk/src/pixbuf.ccg      |   40 ++++++++++++++++++++++++++++++++++++++++
 gdk/src/pixbuf.hg       |   15 +++++++++++++++
 tools/m4/convert_gdk.m4 |    1 +
 5 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f657ec5..d8feb55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-06-29  Jonathon Jongsma  <jonathon quotidian org>
+
+	* configure.ac:
+	* gdk/src/pixbuf.ccg:
+	* gdk/src/pixbuf.hg:
+	* tools/m4/convert_gdk.m4: add Gdk::Pixbuf::create_for_stream() and
+	  create_for_stream_at_scale() for reading pixbufs from Gio file
+	  streams
+
 2.17.1:
 
 2009-06-22  Hubert Figuiere  <hub figuiere net>
diff --git a/configure.ac b/configure.ac
index 7556da5..4c60af4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,6 +223,7 @@ AC_SUBST(ATKMM_LIBS)
 
 # gdkmm really does need GTK+, because part of Gdk::DragContext is in GTK+.
 PKG_CHECK_MODULES(GDKMM, glibmm-2.4 >= ${gtkmm_min_glibmm_version}
+                         giomm-2.4 >= ${gtkmm_min_glibmm_version}
                          cairomm-1.0 >= ${gtkmm_min_cairomm_version}
                          pangomm-1.4 >= ${gtkmm_min_pangomm_version}
                          gtk+-2.0 >= ${gtkmm_min_gtk_version})
diff --git a/gdk/src/pixbuf.ccg b/gdk/src/pixbuf.ccg
index 1e7f2aa..575a648 100644
--- a/gdk/src/pixbuf.ccg
+++ b/gdk/src/pixbuf.ccg
@@ -153,6 +153,46 @@ Glib::RefPtr<Pixbuf> Pixbuf::create_from_data(const guint8* data, Colorspace col
   return Glib::wrap(pixbuf);
 }
 
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<Pixbuf> Pixbuf::create_from_stream(const Glib::RefPtr<Gio::InputStream>& stream)
+#else
+Glib::RefPtr<Pixbuf> Pixbuf::create_from_stream(const Glib::RefPtr<Gio::InputStream>& stream, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  GError* gerror = 0;
+  Glib::RefPtr<Pixbuf> retvalue = Glib::wrap(gdk_pixbuf_new_from_stream(const_cast<GInputStream*>(Glib::unwrap(stream)), 0, &(gerror)));
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return retvalue;
+}
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+Glib::RefPtr<Pixbuf> Pixbuf::create_from_stream_at_scale(const Glib::RefPtr<Gio::InputStream>& stream, int width, int height, bool preserve_aspect_ratio)
+#else
+Glib::RefPtr<Pixbuf> Pixbuf::create_from_stream_at_scale(const Glib::RefPtr<Gio::InputStream>& stream, int width, int height, bool preserve_aspect_ratio, std::auto_ptr<Glib::Error>& error)
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+{
+  GError* gerror = 0;
+  Glib::RefPtr<Pixbuf> retvalue = Glib::wrap(gdk_pixbuf_new_from_stream_at_scale(const_cast<GInputStream*>(Glib::unwrap(stream)), width, height, static_cast<int>(preserve_aspect_ratio), 0, &(gerror)));
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  if(gerror)
+    ::Glib::Error::throw_exception(gerror);
+#else
+  if(gerror)
+    error = ::Glib::Error::throw_exception(gerror);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  return retvalue;
+}
+
 void Pixbuf::render_pixmap_and_mask_for_colormap(const Glib::RefPtr<Colormap>& colormap,
                                                  Glib::RefPtr<Pixmap>& pixmap_return,
                                                  Glib::RefPtr<Bitmap>& mask_return,
diff --git a/gdk/src/pixbuf.hg b/gdk/src/pixbuf.hg
index 7421833..46bb19d 100644
--- a/gdk/src/pixbuf.hg
+++ b/gdk/src/pixbuf.hg
@@ -27,6 +27,7 @@ _CONFIGINCLUDE(gdkmmconfig.h)
 #include <gdkmm/bitmap.h>
 #include <gdkmm/pixbufformat.h>
 #include <gdkmm/types.h>
+#include <giomm/inputstream.h>
 
 _DEFS(gdkmm,gdk)
 _PINCLUDE(glibmm/private/object_p.h)
@@ -386,6 +387,20 @@ public:
   _WRAP_METHOD(static Glib::RefPtr<Pixbuf> create_from_inline(int data_length, const guint8* data,
                                                  bool copy_pixels = false), gdk_pixbuf_new_from_inline, errthrow)
 
+  _WRAP_METHOD(static Glib::RefPtr<Pixbuf> create_from_stream(const Glib::RefPtr<Gio::InputStream>& stream, const Glib::RefPtr<Gio::Cancellable>& cancelable), gdk_pixbuf_new_from_stream, errthrow)
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  static Glib::RefPtr<Pixbuf> create_from_stream(const Glib::RefPtr<Gio::InputStream>& stream);
+#else
+  static Glib::RefPtr<Pixbuf> create_from_stream(const Glib::RefPtr<Gio::InputStream>& stream, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+  _WRAP_METHOD(static Glib::RefPtr<Pixbuf> create_from_stream_at_scale(const Glib::RefPtr<Gio::InputStream>& stream, int width, int height, bool preserve_aspect_ratio, const Glib::RefPtr<Gio::Cancellable>& cancelable), gdk_pixbuf_new_from_stream_at_scale, errthrow)
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+  static Glib::RefPtr<Pixbuf> create_from_stream_at_scale(const Glib::RefPtr<Gio::InputStream>& stream, int width, int height, bool preserve_aspect_ratio);
+#else
+  static Glib::RefPtr<Pixbuf> create_from_stream_at_scale(const Glib::RefPtr<Gio::InputStream>& stream, int width, int height, bool preserve_aspect_ratio, std::auto_ptr<Glib::Error>& error);
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
 
   _WRAP_METHOD(Colorspace get_colorspace() const, gdk_pixbuf_get_colorspace)
 
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index 2c23287..21fe9d4 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -1,4 +1,5 @@
 include(convert_glib.m4)
+include(convert_gio.m4)
 
 _EQUAL(gint8[],gint8*)
 _EQUAL(guchar,guint8)



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