From 66aacf96330c978af4fadd9abdde3c092780d646 Mon Sep 17 00:00:00 2001 From: Jacob Boerema Date: Tue, 21 Jan 2025 11:33:10 -0500 Subject: [PATCH] plug-ins: add support for loading 16-bit per channel LAB psd's --- plug-ins/file-psd/psd-load.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c index 00084bb69c..6b74decb3b 100644 --- a/plug-ins/file-psd/psd-load.c +++ b/plug-ins/file-psd/psd-load.c @@ -600,8 +600,7 @@ read_header_block (PSDimage *img_a, if (img_a->color_mode == PSD_CMYK || img_a->color_mode == PSD_LAB) { - if (img_a->bps != 8 && - (img_a->bps != 16 || img_a->color_mode == PSD_LAB)) + if (img_a->bps != 8 && img_a->bps != 16) { g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED, _("Unsupported color mode: %s"), @@ -1606,7 +1605,7 @@ create_gimp_image (PSDimage *img_a, break; case 16: - if (img_a->color_mode == PSD_CMYK) + if (img_a->color_mode == PSD_CMYK || img_a->color_mode == PSD_LAB) precision = GIMP_PRECISION_FLOAT_NON_LINEAR; else precision = GIMP_PRECISION_U16_NON_LINEAR; @@ -1765,11 +1764,17 @@ psd_convert_lab_to_srgb (PSDimage *img_a, gboolean alpha) { const Babl *fish; + const Babl *base_format = NULL; + + if (img_a->bps == 8) + base_format = babl_format (alpha ? "CIE Lab alpha u8" : "CIE Lab u8"); + else + base_format = babl_format (alpha ? "CIE Lab alpha u16" : "CIE Lab u16"); if (alpha) - fish = babl_fish ("CIE Lab alpha u8", "R'G'B'A float"); + fish = babl_fish (base_format, "R'G'B'A float"); else - fish = babl_fish ("CIE Lab u8", "R'G'B' float"); + fish = babl_fish (base_format, "R'G'B' float"); babl_process (fish, src, dst, width * height); @@ -3684,7 +3689,8 @@ get_layer_format (PSDimage *img_a, break; case 16: - format = babl_format (img_a->color_mode == PSD_CMYK ? "R'G'B' float" : "R'G'B' u16"); + format = babl_format ((img_a->color_mode == PSD_CMYK || img_a->color_mode == PSD_LAB) ? + "R'G'B' float" : "R'G'B' u16"); break; case 8: @@ -3707,7 +3713,8 @@ get_layer_format (PSDimage *img_a, break; case 16: - format = babl_format (img_a->color_mode == PSD_CMYK ? "R'G'B'A float" : "R'G'B'A u16"); + format = babl_format ((img_a->color_mode == PSD_CMYK || img_a->color_mode == PSD_LAB) ? + "R'G'B'A float" : "R'G'B'A u16"); break; case 8: