[gtk/image-loading: 10/14] Use our tiff loader for content (de)serialization




commit 59475d11e8085d7923ec52bd9a187573ed0d7c99
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Sep 9 23:05:01 2021 -0400

    Use our tiff loader for content (de)serialization
    
    We still fall back to gdk-pixbuf for handling all
    the other image formats.

 gdk/gdkcontentdeserializer.c |  9 +++++++++
 gdk/gdkcontentserializer.c   | 14 ++++++++++++++
 2 files changed, 23 insertions(+)
---
diff --git a/gdk/gdkcontentdeserializer.c b/gdk/gdkcontentdeserializer.c
index 64a0f3b1db..4c18675d55 100644
--- a/gdk/gdkcontentdeserializer.c
+++ b/gdk/gdkcontentdeserializer.c
@@ -26,6 +26,7 @@
 #include "gdktexture.h"
 #include "gdkrgbaprivate.h"
 #include "loaders/gdkpngprivate.h"
+#include "loaders/gdktiffprivate.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
@@ -721,6 +722,8 @@ deserialize_texture_in_thread (GTask        *task,
 
   if (strcmp (gdk_content_deserializer_get_mime_type (deserializer), "image/png") == 0)
     texture = gdk_load_png (bytes, &error);
+  else if (strcmp (gdk_content_deserializer_get_mime_type (deserializer), "image/tiff") == 0)
+    texture = gdk_load_tiff (bytes, &error);
   else
     g_assert_not_reached ();
 
@@ -959,6 +962,12 @@ init (void)
                                      NULL,
                                      NULL);
 
+  gdk_content_register_deserializer ("image/tiff",
+                                     GDK_TYPE_TEXTURE,
+                                     texture_deserializer,
+                                     NULL,
+                                     NULL);
+
   formats = gdk_pixbuf_get_formats ();
 
   /* Make sure png comes first */
diff --git a/gdk/gdkcontentserializer.c b/gdk/gdkcontentserializer.c
index f884595630..854f779187 100644
--- a/gdk/gdkcontentserializer.c
+++ b/gdk/gdkcontentserializer.c
@@ -27,6 +27,7 @@
 #include "gdktextureprivate.h"
 #include "gdkrgba.h"
 #include "loaders/gdkpngprivate.h"
+#include "loaders/gdktiffprivate.h"
 #include "gdkmemorytextureprivate.h"
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
@@ -711,6 +712,14 @@ serialize_texture_in_thread (GTask        *task,
                            data->stride,
                            data->format,
                            &error);
+  else if (strcmp (gdk_content_serializer_get_mime_type (serializer), "image/tiff") == 0)
+    result = gdk_save_tiff (gdk_content_serializer_get_output_stream (serializer),
+                            g_bytes_get_data (data->bytes, NULL),
+                            data->width,
+                            data->height,
+                            data->stride,
+                            data->format,
+                            &error);
   else
     g_assert_not_reached ();
 
@@ -982,6 +991,11 @@ init (void)
                                    texture_serializer,
                                    NULL, NULL);
 
+  gdk_content_register_serializer (GDK_TYPE_TEXTURE,
+                                   "image/tiff",
+                                   texture_serializer,
+                                   NULL, NULL);
+
   formats = gdk_pixbuf_get_formats ();
 
   /* Make sure png comes first */


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