summaryrefslogtreecommitdiff
path: root/source/fitz/output-psd.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-07-13 17:32:32 +0100
committerRobin Watts <robin.watts@artifex.com>2017-09-08 17:48:07 +0100
commit7e4a177d55b3a290300f6671c0670e5a5897da24 (patch)
tree81190342149dc508787247efa78854383997cad8 /source/fitz/output-psd.c
parenta7f36241cba4d1807ab4664201aa0975755d6772 (diff)
downloadmupdf-7e4a177d55b3a290300f6671c0670e5a5897da24.tar.xz
Update fz_separations equivalent color mechanism.
Incorporates fixes from Michael. Rather than specifically giving it rgb and cmyk values, separations now include the colorspace. Conversions can then be done into ANY colorspace we need. Note, that we maintain the old way of working for the gproof device. Also, fix pdf_page_separations to correctly find all separations. This involves recursively looking through colorspaces, forms and shadings for colorspaces therein, making sure we don't run into any circular references. We do 2 passes, so that we can pick up as many colorants as Separations as possible. On the second pass we pick up any colorants we missed in terms of DeviceN spaces. The purpose of this is to try to ensure that we get as many tint transforms as single input functions as we can. This may not be important in the grand scheme of things, but seems neater.
Diffstat (limited to 'source/fitz/output-psd.c')
-rw-r--r--source/fitz/output-psd.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source/fitz/output-psd.c b/source/fitz/output-psd.c
index 4d0f9574..d39051dd 100644
--- a/source/fitz/output-psd.c
+++ b/source/fitz/output-psd.c
@@ -74,6 +74,9 @@ psd_write_header(fz_context *ctx, fz_band_writer *writer_, const fz_colorspace *
fz_buffer *buffer = fz_icc_data_from_icc_colorspace(ctx, cs);
unsigned char *data;
size_t size = fz_buffer_storage(ctx, buffer, &data);
+ const fz_colorspace *cs_cmyk = cs;
+ if (fz_colorspace_n(ctx, cs) != 4)
+ cs_cmyk = fz_device_cmyk(ctx);
if (!fz_colorspace_is_subtractive(ctx, cs))
writer->num_additive = fz_colorspace_n(ctx, cs);
@@ -110,7 +113,7 @@ psd_write_header(fz_context *ctx, fz_band_writer *writer_, const fz_colorspace *
len = 0;
for (i = 0; i < s; i++)
{
- const char *name = fz_get_separation(ctx, seps, i, NULL, NULL);
+ const char *name = fz_separation_name(ctx, seps, i);
char text[32];
size_t len2;
if (name == NULL)
@@ -140,7 +143,7 @@ psd_write_header(fz_context *ctx, fz_band_writer *writer_, const fz_colorspace *
fz_write_int32_be(ctx, out, (len + 1)&~1);
for (i = 0; i < s; i++) {
size_t len2;
- const char *name = fz_get_separation(ctx, seps, i, NULL, NULL);
+ const char *name = fz_separation_name(ctx, seps, i);
char text[32];
if (name == NULL)
{
@@ -164,14 +167,14 @@ psd_write_header(fz_context *ctx, fz_band_writer *writer_, const fz_colorspace *
fz_write_int16_be(ctx, out, 0); /* PString */
fz_write_int32_be(ctx, out, 14 * s); /* Length */
for (i = 0; i < s; i++) {
- uint32_t cmyk;
- (void)fz_get_separation(ctx, seps, i, NULL, &cmyk);
+ float cmyk[4];
+ fz_separation_equivalent(ctx, seps, i, NULL, cs_cmyk, NULL, cmyk);
fz_write_int16_be(ctx, out, 02); /* CMYK */
/* PhotoShop stores all component values as if they were additive. */
- fz_write_int16_be(ctx, out, 257 * (cmyk & 0xFF));/* Cyan */
- fz_write_int16_be(ctx, out, 257 * ((cmyk>>8) & 0xFF));/* Magenta */
- fz_write_int16_be(ctx, out, 257 * ((cmyk>>16) & 0xFF));/* Yellow */
- fz_write_int16_be(ctx, out, 257 * ((cmyk>>24) & 0xFF));/* Black */
+ fz_write_int16_be(ctx, out, 65535 * (1-cmyk[0]));/* Cyan */
+ fz_write_int16_be(ctx, out, 65535 * (1-cmyk[1]));/* Magenta */
+ fz_write_int16_be(ctx, out, 65535 * (1-cmyk[2]));/* Yellow */
+ fz_write_int16_be(ctx, out, 65535 * (1-cmyk[3]));/* Black */
fz_write_int16_be(ctx, out, 0); /* Opacity 0 to 100 */
fz_write_byte(ctx, out, 2); /* Don't know */
fz_write_byte(ctx, out, 0); /* Padding - Always Zero */