[gtk/image-loading: 6/15] Add gdk_texture_save_to_png_bytes




commit 2a06072c3dd80f21d49a25ad69a3c105df1677e2
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Sep 13 14:29:31 2021 -0400

    Add gdk_texture_save_to_png_bytes
    
    Just expose what we already have available
    internally, so e.g. tests can use it without
    static linking.

 gdk/gdktexture.c | 23 +++++++++++++++++++++++
 gdk/gdktexture.h |  2 ++
 2 files changed, 25 insertions(+)
---
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index 8bcf17d705..5acab3c3c7 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -681,3 +681,26 @@ gdk_texture_save_to_png (GdkTexture *texture,
 
   return result;
 }
+
+/**
+ * gdk_texture_save_to_png_bytes:
+ * @texture: a `GdkTexture`
+ *
+ * Store the given @texture in memory as a PNG file.
+ *
+ * This is a utility function intended for debugging and testing.
+ * If you want more control over formats, proper error handling or
+ * want to store to a `GFile` or other location, you might want to
+ * look into using the gdk-pixbuf library.
+ *
+ * Returns: a newly allocated `GBytes` containing PNG data
+ *
+ * Since: 4.6
+ */
+GBytes *
+gdk_texture_save_to_png_bytes (GdkTexture *texture)
+{
+  g_return_val_if_fail (GDK_IS_TEXTURE (texture), NULL);
+
+  return gdk_save_png (texture);
+}
diff --git a/gdk/gdktexture.h b/gdk/gdktexture.h
index 7cccdb5928..41b9f3d7e7 100644
--- a/gdk/gdktexture.h
+++ b/gdk/gdktexture.h
@@ -69,6 +69,8 @@ void                    gdk_texture_download_float             (GdkTexture
 GDK_AVAILABLE_IN_ALL
 gboolean                gdk_texture_save_to_png                (GdkTexture      *texture,
                                                                 const char      *filename);
+GDK_AVAILABLE_IN_4_6
+GBytes *                gdk_texture_save_to_png_bytes          (GdkTexture      *texture);
 
 G_END_DECLS
 


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