[gimp] plug-ins: in file-psd, fix u8 channel format



commit 251ce5126ea3b5a890f1c1d80af2c75071c3ce7c
Author: Ell <ell_se yahoo com>
Date:   Sun Apr 26 22:39:34 2020 +0300

    plug-ins: in file-psd, fix u8 channel format
    
    In file-psd, use a non-linear channel format when the image
    precision is u8 non-linear, as per gimp_image_get_channel_format().

 plug-ins/file-psd/psd-load.c |  3 ++-
 plug-ins/file-psd/psd-save.c | 24 +++++++++++++++++++-----
 2 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index a4ecf27ec7..5955bde6b9 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -2552,7 +2552,8 @@ get_channel_format (PSDimage *img_a)
 
     case 8:
     case 1:
-      format = babl_format ("Y u8");
+      /* see gimp_image_get_channel_format() */
+      format = babl_format ("Y' u8");
       break;
 
     default:
diff --git a/plug-ins/file-psd/psd-save.c b/plug-ins/file-psd/psd-save.c
index 3a67f9b1bf..67265dcaf8 100644
--- a/plug-ins/file-psd/psd-save.c
+++ b/plug-ins/file-psd/psd-save.c
@@ -1766,6 +1766,7 @@ get_bpc (GimpImage *image)
 static const Babl *
 get_pixel_format (GimpDrawable *drawable)
 {
+  GimpImage   *image = gimp_item_get_image (GIMP_ITEM (drawable));
   const gchar *model;
   gint         bpc;
   gchar        format[32];
@@ -1796,7 +1797,7 @@ get_pixel_format (GimpDrawable *drawable)
       g_return_val_if_reached (NULL);
     }
 
-  bpc = get_bpc (gimp_item_get_image (GIMP_ITEM (drawable)));
+  bpc = get_bpc (image);
 
   sprintf (format, "%s u%d", model, 8 * bpc);
 
@@ -1806,10 +1807,15 @@ get_pixel_format (GimpDrawable *drawable)
 static const Babl *
 get_channel_format (GimpDrawable *drawable)
 {
-  gint  bpc;
-  gchar format[32];
+  GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
+  gint       bpc;
+  gchar      format[32];
+
+  /* see gimp_image_get_channel_format() */
+  if (gimp_image_get_precision (image) == GIMP_PRECISION_U8_NON_LINEAR)
+    return babl_format ("Y' u8");
 
-  bpc = get_bpc (gimp_item_get_image (GIMP_ITEM (drawable)));
+  bpc = get_bpc (image);
 
   sprintf (format, "Y u%d", 8 * bpc);
 
@@ -1819,7 +1825,15 @@ get_channel_format (GimpDrawable *drawable)
 static const Babl *
 get_mask_format (GimpLayerMask *mask)
 {
-  return get_channel_format (GIMP_DRAWABLE (mask));
+  GimpImage *image = gimp_item_get_image (GIMP_ITEM (mask));
+  gint       bpc;
+  gchar      format[32];
+
+  bpc = get_bpc (image);
+
+  sprintf (format, "Y u%d", 8 * bpc);
+
+  return babl_format (format);
 }
 
 static GList *


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