[gtk/wip/otte/color-profiles: 75/82] jpeg: Save color profile information




commit ba6c03e9027f9de789447349f743e6f08e9cdd83
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Sep 29 14:26:18 2021 -0400

    jpeg: Save color profile information
    
    When writing a jpeg image, include the icc profile.

 gdk/loaders/gdkjpeg.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/gdk/loaders/gdkjpeg.c b/gdk/loaders/gdkjpeg.c
index ae1c91a4d1..164459869d 100644
--- a/gdk/loaders/gdkjpeg.c
+++ b/gdk/loaders/gdkjpeg.c
@@ -301,9 +301,12 @@ gdk_save_jpeg (GdkTexture *texture)
   guchar *input = NULL;
   guchar *row;
   int width, height, stride;
+  GdkColorProfile *color_profile;
+  GBytes *bytes;
 
   width = gdk_texture_get_width (texture);
   height = gdk_texture_get_height (texture);
+  color_profile = gdk_texture_get_color_profile (texture);
 
   info.err = jpeg_std_error (&jerr.pub);
   jerr.pub.error_exit = fatal_error_handler;
@@ -337,6 +340,12 @@ gdk_save_jpeg (GdkTexture *texture)
 
   jpeg_start_compress (&info, TRUE);
 
+  bytes = gdk_color_profile_get_icc_profile (color_profile);
+  jpeg_write_icc_profile (&info,
+                          g_bytes_get_data (bytes, NULL),
+                          g_bytes_get_size (bytes));
+  g_bytes_unref (bytes);
+
   while (info.next_scanline < info.image_height)
     {
       row = &input[info.next_scanline * stride];


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