[gtk/image-loading: 17/18] Load jpegs without gdk-pixbuf




commit 7dd10163961fa630861f46ab0d425bb9a943d135
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Sep 11 17:02:41 2021 -0400

    Load jpegs without gdk-pixbuf
    
    Use our own loader for jpeg files.

 gdk/gdktexture.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/gdk/gdktexture.c b/gdk/gdktexture.c
index 0c80e2c4de..5c7af9697c 100644
--- a/gdk/gdktexture.c
+++ b/gdk/gdktexture.c
@@ -48,6 +48,7 @@
 #include <graphene.h>
 #include "gdkpng.h"
 #include "gdktiff.h"
+#include "gdkjpeg.h"
 
 /* HACK: So we don't need to include any (not-yet-created) GSK or GTK headers */
 void
@@ -396,6 +397,13 @@ gdk_texture_new_from_file (GFile   *file,
       return texture;
     }
 
+  if (memcmp (data, "\xff\xd8", 2) == 0)
+    {
+      texture = gdk_load_jpeg (stream, error);
+      g_object_unref (stream);
+      return texture;
+    }
+
   pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error);
   g_object_unref (stream);
   if (pixbuf == NULL)


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