[gimp/gimp-2-10] plug-ins: in file-psd, use scratch allocator for temporary CMYK buffers; cleanup



commit 6e6366e53ce89bbad57e7d03b9226b8fb9ad14f0
Author: Ell <ell_se yahoo com>
Date:   Sat Feb 22 18:20:13 2020 +0200

    plug-ins: in file-psd, use scratch allocator for temporary CMYK buffers; cleanup
    
    (cherry picked from commit 1b6191d176f6cc06697b08b0af8d03ad6a818b73)

 plug-ins/file-psd/psd-load.c | 51 +++++++++++---------------------------------
 1 file changed, 13 insertions(+), 38 deletions(-)
---
diff --git a/plug-ins/file-psd/psd-load.c b/plug-ins/file-psd/psd-load.c
index fefae1708c..a73011efe8 100644
--- a/plug-ins/file-psd/psd-load.c
+++ b/plug-ins/file-psd/psd-load.c
@@ -1631,44 +1631,8 @@ add_layers (gint32     image_id,
 
                           if (img_a->color_mode == PSD_CMYK)
                             {
-                              guchar              *cmyk = g_new (guchar, layer_channels * iter->length);
-
-                              for (cidx = 0; cidx < layer_channels; ++cidx)
-                                {
-                                  gint b, y, x;
-
-                                  if (roi->x == 0 && roi->y == 0)
-                                    IFDBG(3) g_debug ("Start channel %d", channel_idx[cidx]);
-
-                                  for (b = 0; b < bps; ++b)
-                                    {
-                                      guint8 *dst = &cmyk[cidx * bps + b];
-
-                                      for (y = 0; y < roi->height; y++)
-                                        {
-                                          const guint8 *src;
-
-                                          src = (const guint8 *)
-                                            &lyr_chn[channel_idx[cidx]]->data[
-                                            ((roi->y + y) * l_w +
-                                             roi->x)      * bps +
-                                              b];
-
-                                          for (x = 0; x < roi->width; ++x)
-                                            {
-                                              *dst = *src;
-
-                                              src += src_step;
-                                              dst += dst_step;
-                                            }
-                                        }
-                                    }
-                                }
-
-                              psd_convert_cmyk_to_srgb (img_a, dst0, cmyk, roi->width, roi->height, alpha);
-
-                              g_free (cmyk);
-                              continue;
+                              dst0 = gegl_scratch_alloc (layer_channels *
+                                                         iter->length);
                             }
 
                           for (cidx = 0; cidx < layer_channels; ++cidx)
@@ -1706,6 +1670,17 @@ add_layers (gint32     image_id,
                                     }
                                 }
                             }
+
+                          if (img_a->color_mode == PSD_CMYK)
+                            {
+                              psd_convert_cmyk_to_srgb (
+                                img_a,
+                                iter->items[0].data, dst0,
+                                roi->width, roi->height,
+                                alpha);
+
+                              gegl_scratch_free (dst0);
+                            }
                         }
 
                       for (cidx = 0; cidx < layer_channels; ++cidx)


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