plug-ins: in file-psd, use scratch allocator for temporary CMYK buffers; cleanup

This commit is contained in:
Ell 2020-02-22 18:20:13 +02:00
parent d868247fd9
commit 1b6191d176
1 changed files with 13 additions and 38 deletions

View File

@ -1642,44 +1642,8 @@ add_layers (GimpImage *image,
if (img_a->color_mode == PSD_CMYK) if (img_a->color_mode == PSD_CMYK)
{ {
guchar *cmyk = g_new (guchar, layer_channels * iter->length); dst0 = gegl_scratch_alloc (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;
} }
for (cidx = 0; cidx < layer_channels; ++cidx) for (cidx = 0; cidx < layer_channels; ++cidx)
@ -1717,6 +1681,17 @@ add_layers (GimpImage *image,
} }
} }
} }
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) for (cidx = 0; cidx < layer_channels; ++cidx)