[gtk/image-loading: 46/59] texture: Add gdk_texture_save_to_tiff_bytes()




commit b1bb7c3258f62d9d9d81f8135f0ae8af38f3c799
Author: Benjamin Otte <otte redhat com>
Date:   Tue Sep 14 02:36:56 2021 +0200

    texture: Add gdk_texture_save_to_tiff_bytes()

 gdk/gdktexture.c | 34 ++++++++++++++++++++++++++++++++++
 gdk/gdktexture.h |  2 ++
 2 files changed, 36 insertions(+)
---
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index 7a8a324e37..ea186a8bc0 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -743,6 +743,10 @@ gdk_texture_save_to_png (GdkTexture *texture,
  * attaching metadata, you should look into an image handling
  * library such as the gdk-pixbuf library.
  *
+ * If you are dealing with high dynamic range float data, you
+ * might also want to consider [method@Gdk.Texture.save_to_tiff_bytes]
+ * instead.
+ *
  * Returns: a newly allocated `GBytes` containing PNG data
  *
  * Since: 4.6
@@ -786,3 +790,33 @@ gdk_texture_save_to_tiff (GdkTexture  *texture,
 
   return result;
 }
+
+/**
+ * gdk_texture_save_to_tiff_bytes:
+ * @texture: a `GdkTexture`
+ *
+ * Store the given @texture in memory as a TIFF file.
+ *
+ * Use [ctor@Gdk.Texture.new_from_bytes] to read it back.
+ *
+ * This function is intended to store a representation of the
+ * texture's data that is as accurate as possible. This is
+ * particularly relevant when working with high dynamic range
+ * images and floating-point texture data.
+ *
+ * If that is not your concern and you are interested in a
+ * smaller size and a more portable format, you might want to
+ * use [method@Gdk.Texture.save_to_png_bytes].
+ *
+ * Returns: a newly allocated `GBytes` containing TIFF data
+ *
+ * Since: 4.6
+ */
+GBytes *
+gdk_texture_save_to_tiff_bytes (GdkTexture *texture)
+{
+  g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
+
+  return gdk_save_tiff (texture);
+}
+
diff --git a/gdk/gdktexture.h b/gdk/gdktexture.h
index 8d46702b79..aba864e39f 100644
--- a/gdk/gdktexture.h
+++ b/gdk/gdktexture.h
@@ -96,6 +96,8 @@ GBytes *                gdk_texture_save_to_png_bytes          (GdkTexture
 GDK_AVAILABLE_IN_4_6
 gboolean                gdk_texture_save_to_tiff               (GdkTexture      *texture,
                                                                 const char      *filename);
+GDK_AVAILABLE_IN_4_6
+GBytes *                gdk_texture_save_to_tiff_bytes         (GdkTexture      *texture);
 
 G_END_DECLS
 


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