[gdk-pixbuf] gdk-pixbuf: Add gdk_pixbuf_copy_options() helper



commit f2206a38a9a2d90b65e4095294f8505068081bb8
Author: Bastien Nocera <hadess hadess net>
Date:   Sat Jun 25 19:28:58 2016 +0200

    gdk-pixbuf: Add gdk_pixbuf_copy_options() helper
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768043

 gdk-pixbuf/gdk-pixbuf-core.h |    3 +++
 gdk-pixbuf/gdk-pixbuf.c      |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-core.h b/gdk-pixbuf/gdk-pixbuf-core.h
index f6674d6..30ef57e 100644
--- a/gdk-pixbuf/gdk-pixbuf-core.h
+++ b/gdk-pixbuf/gdk-pixbuf-core.h
@@ -539,6 +539,9 @@ const gchar * gdk_pixbuf_get_option (GdkPixbuf   *pixbuf,
                                               const gchar *key);
 GDK_PIXBUF_AVAILABLE_IN_2_32
 GHashTable * gdk_pixbuf_get_options (GdkPixbuf   *pixbuf);
+GDK_PIXBUF_AVAILABLE_IN_2_36
+gboolean gdk_pixbuf_copy_options (GdkPixbuf *src_pixbuf,
+                                  GdkPixbuf *dest_pixbuf);
 
 
 G_END_DECLS
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index c39ec8c..8b0dad7 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -1022,6 +1022,46 @@ gdk_pixbuf_set_option (GdkPixbuf   *pixbuf,
         return TRUE;
 }
 
+/**
+ * gdk_pixbuf_copy_options:
+ * @src_pixbuf: a #GdkPixbuf to copy options from
+ * @dest_pixbuf: the #GdkPixbuf to copy options to
+ *
+ * Copy the key/value pair options attached to a #GdkPixbuf to another.
+ * This is useful to keep original metadata after having manipulated
+ * a file. However be careful to remove metadata which you've already
+ * applied, such as the "orientation" option after rotating the image.
+ *
+ * Return value: %TRUE on success.
+ *
+ * Since: 2.36
+ **/
+gboolean
+gdk_pixbuf_copy_options (GdkPixbuf *src_pixbuf,
+                         GdkPixbuf *dest_pixbuf)
+{
+        GQuark  quark;
+        gchar **options;
+
+        g_return_val_if_fail (GDK_IS_PIXBUF (src_pixbuf), FALSE);
+        g_return_val_if_fail (GDK_IS_PIXBUF (dest_pixbuf), FALSE);
+
+        quark = g_quark_from_static_string ("gdk_pixbuf_options");
+
+        options = g_object_dup_qdata (G_OBJECT (src_pixbuf),
+                                      quark,
+                                      (GDuplicateFunc) g_strdupv,
+                                      NULL);
+
+        if (options == NULL)
+                return TRUE;
+
+        g_object_set_qdata_full (G_OBJECT (dest_pixbuf), quark,
+                                 options, (GDestroyNotify) g_strfreev);
+
+        return TRUE;
+}
+
 static void
 gdk_pixbuf_set_property (GObject         *object,
                         guint            prop_id,


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