[gegl] png-save: only look for "linear" variant of 1.0 trc



commit 8b1705a083f586feabc1d2070d1b6f3e669836b3
Author: Øyvind Kolås <pippin gimp org>
Date:   Fri Jul 13 12:21:37 2018 +0200

    png-save: only look for "linear" variant of 1.0 trc

 operations/external/png-save.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
---
diff --git a/operations/external/png-save.c b/operations/external/png-save.c
index 1f63b8896..40d940f0b 100644
--- a/operations/external/png-save.c
+++ b/operations/external/png-save.c
@@ -150,12 +150,43 @@ export_png (GeglOperation       *operation,
       png_set_sRGB_gAMA_and_cHRM (png, info, PNG_sRGB_INTENT_RELATIVE);
     }
   else
-    white.gray = 0xff;
+    {
+      double wp[2];
+      double red[2];
+      double green[2];
+      double blue[2];
+      const Babl *trc[3];
+      babl_space_get (space, &wp[0], &wp[1],
+                      &red[0], &red[1],
+                      &green[0], &green[1],
+                      &blue[0], &blue[1],
+                      &trc[0], &trc[1], &trc[2]);
+      png_set_cHRM (png, info, wp[0], wp[1], red[0], red[1], green[0], green[1], blue[0], blue[1]);
+      /* XXX: should also set gamma based on trc! */
+      if (trc[0] == babl_trc("sRGB") ||
+          trc[0] == babl_trc("2.2"))
+      {
+        png_set_gAMA (png, info, 2.22);
+      }
+      else if (trc[0] == babl_trc("linear"))
+      {
+        png_set_gAMA (png, info, 1.0);
+      }
+      else
+      {
+        png_set_gAMA (png, info, 2.2);
+      }
+
+      white.gray = 0xff;
+    }
   png_set_bKGD (png, info, &white);
 
 
   format = babl_format_with_space (format_string, space);
 
+  {
+  }
+
   if (space && space != babl_space("sRGB")){
     int icc_len;
     const char *name = babl_get_name (space);


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