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




commit c558425efab71b0185a911db4a8f6eb8e6c820bd
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   | 8 ++++++++
 2 files changed, 17 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 8421bd4964..e2999e84f2 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>
@@ -693,6 +694,8 @@ serialize_texture_in_thread (GTask        *task,
 
   if (strcmp (gdk_content_serializer_get_mime_type (serializer), "image/png") == 0)
     bytes = gdk_save_png (texture);
+  else if (strcmp (gdk_content_serializer_get_mime_type (serializer), "image/tiff") == 0)
+    bytes = gdk_save_tiff (texture);
   else
     g_assert_not_reached ();
 
@@ -959,6 +962,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]