[gtk/image-loading: 26/28] texture: Add gdk_texture_save_to_tiff_bytes()




commit a303edc1c6cc45134957c4549d88e74a173e0576
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 a8ede20687..4573acc06c 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -710,6 +710,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
@@ -753,3 +757,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 ce1ccf2642..59ba657607 100644
--- a/gdk/gdktexture.h
+++ b/gdk/gdktexture.h
@@ -93,6 +93,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]