[gtk/image-loading: 14/36] Add gdk_texture_save_to_tiff




commit 185d04bdebae279aba3dc9e79a26f5d94f0dfd72
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Sep 7 09:20:05 2021 -0400

    Add gdk_texture_save_to_tiff
    
    This is a companion to gdk_texture_save_to_png, using
    the tiff format, which will let us avoid lossy conversion
    of HDR data, since we can store floating point data.

 gdk/gdktexture.c | 32 ++++++++++++++++++++++++++++++++
 gdk/gdktexture.h |  3 +++
 2 files changed, 35 insertions(+)
---
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index 7f9590159c..f42e25a4e5 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -719,3 +719,35 @@ gdk_texture_save_to_png_bytes (GdkTexture *texture)
 
   return gdk_save_png (texture);
 }
+
+/**
+ * gdk_texture_save_to_tiff:
+ * @texture: a `GdkTexture`
+ * @filename: (type filename): the filename to store to
+ *
+ * Store the given @texture to the @filename as a TIFF file.
+ *
+ * GTK will attempt to store data without loss.
+ * Returns: %TRUE if saving succeeded, %FALSE on failure.
+ *
+ * Since: 4.6
+ */
+gboolean
+gdk_texture_save_to_tiff (GdkTexture  *texture,
+                          const char  *filename)
+{
+  GBytes *bytes;
+  gboolean result;
+
+  g_return_val_if_fail (GDK_IS_TEXTURE (texture), FALSE);
+  g_return_val_if_fail (filename != NULL, FALSE);
+
+  bytes = gdk_save_tiff (texture);
+  result = g_file_set_contents (filename,
+                                g_bytes_get_data (bytes, NULL),
+                                g_bytes_get_size (bytes),
+                                NULL);
+  g_bytes_unref (bytes);
+
+  return result;
+}
diff --git a/gdk/gdktexture.h b/gdk/gdktexture.h
index a8e6c32099..ce1ccf2642 100644
--- a/gdk/gdktexture.h
+++ b/gdk/gdktexture.h
@@ -90,6 +90,9 @@ gboolean                gdk_texture_save_to_png                (GdkTexture
                                                                 const char      *filename);
 GDK_AVAILABLE_IN_4_6
 GBytes *                gdk_texture_save_to_png_bytes          (GdkTexture      *texture);
+GDK_AVAILABLE_IN_4_6
+gboolean                gdk_texture_save_to_tiff               (GdkTexture      *texture,
+                                                                const char      *filename);
 
 G_END_DECLS
 


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