[gimp] plug-ins: avoid converting TIFF extra channels for 8-bit non-linear too.



commit 3c0f7f00bab77b42494b4339e8bdc4576f1ba25f
Author: Jehan <jehan girinstud io>
Date:   Tue Jun 18 18:16:25 2019 +0200

    plug-ins: avoid converting TIFF extra channels for 8-bit non-linear too.
    
    Complete commit ac8ad13f0a131d7efc2c07cf9f33817f45eec02d.
    Channels are Y' on 8-bit non-linear images. So to avoid data conversion,
    this is the only case where we want to consider TIFF channels to be Y'
    as well.

 plug-ins/file-tiff/file-tiff-load.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/file-tiff/file-tiff-load.c b/plug-ins/file-tiff/file-tiff-load.c
index 5f0ecb102b..eda3a8e563 100644
--- a/plug-ins/file-tiff/file-tiff-load.c
+++ b/plug-ins/file-tiff/file-tiff-load.c
@@ -1068,10 +1068,25 @@ load_image (GFile        *file,
                                                 100.0, &color);
               gimp_image_insert_channel (*image, channel[i].ID, -1, 0);
               channel[i].buffer = gimp_drawable_get_buffer (channel[i].ID);
-              channel[i].format = babl_format_new (babl_model ("Y"),
-                                                   type,
-                                                   babl_component ("Y"),
-                                                   NULL);
+
+              /* Unlike color channels, we don't care about the source
+               * TRC for extra channels. We just want to import them
+               * as-is without any value conversion. Since extra
+               * channels are always linear in GIMP, we consider TIFF
+               * extra channels with unspecified data to be linear too.
+               * Only exception are 8-bit non-linear images whose
+               * channel are Y' for legacy/compatibility reasons.
+               */
+              if (image_precision == GIMP_PRECISION_U8_NON_LINEAR)
+                channel[i].format = babl_format_new (babl_model ("Y'"),
+                                                     type,
+                                                     babl_component ("Y'"),
+                                                     NULL);
+              else
+                channel[i].format = babl_format_new (babl_model ("Y"),
+                                                     type,
+                                                     babl_component ("Y"),
+                                                     NULL);
             }
         }
 


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