[gs-commits] ghostpdl branch, pdfi, updated. jbig2dec-0.14-2465-gbb630cc
[email protected] (Nancy Durgin) Thu, 14 Nov 2019 23:35:13 +0000 (UTC)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, pdfi has been updated
via bb630cc20b3a1fe6a65266b0e42384d3fead94af (commit)
from cdb5b2b0f7f662695061092e56ad963b7bce8897 (commit)
----------------------------------------------------------------------
commit bb630cc20b3a1fe6a65266b0e42384d3fead94af
Author: Nancy Durgin <[email protected]>
Date: Thu Nov 14 14:27:52 2019 -0800
Implement /Intent for images
Plus minor code refactor to implement pdfi_setrenderingintent() and use it.
Fixes tests/pdf/icc_v4_profile.pdf
diff --git a/pdf/pdf_colour.c b/pdf/pdf_colour.c
index b2a3bac..ba811e9 100644
--- a/pdf/pdf_colour.c
+++ b/pdf/pdf_colour.c
@@ -279,17 +279,7 @@ int pdfi_ri(pdf_context *ctx)
return 0;
}
n = (pdf_name *)ctx->stack_top[-1];
- if (pdfi_name_is(n, "Perceptual")) {
- code = gs_setrenderingintent(ctx->pgs, 0);
- } else if (pdfi_name_is(n, "Saturation")) {
- code = gs_setrenderingintent(ctx->pgs, 2);
- } else if (pdfi_name_is(n, "RelativeColorimetric")) {
- code = gs_setrenderingintent(ctx->pgs, 1);
- } else if (pdfi_name_is(n, "AbsoluteColorimetric")) {
- code = gs_setrenderingintent(ctx->pgs, 3);
- } else {
- code = gs_error_undefined;
- }
+ code = pdfi_setrenderingintent(ctx, n);
pdfi_pop(ctx, 1);
if (code < 0 && ctx->pdfstoponerror)
return code;
diff --git a/pdf/pdf_gstate.c b/pdf/pdf_gstate.c
index 0ebcbe0..fa91fa7 100644
--- a/pdf/pdf_gstate.c
+++ b/pdf/pdf_gstate.c
@@ -613,17 +613,7 @@ static int GS_RI(pdf_context *ctx, pdf_dict *GS, pdf_dict *stream_dict, pdf_dict
if (code < 0)
return code;
- if (pdfi_name_is(n, "Perceptual")) {
- code = gs_setrenderingintent(ctx->pgs, 0);
- } else if (pdfi_name_is(n, "Saturation")) {
- code = gs_setrenderingintent(ctx->pgs, 2);
- } else if (pdfi_name_is(n, "RelativeColorimetric")) {
- code = gs_setrenderingintent(ctx->pgs, 1);
- } else if (pdfi_name_is(n, "AbsoluteColorimetric")) {
- code = gs_setrenderingintent(ctx->pgs, 3);
- } else {
- code = gs_error_undefined;
- }
+ code = pdfi_setrenderingintent(ctx, n);
pdfi_countdown(n);
return code;
}
diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c
index 63c4e34..4f7a6b5 100644
--- a/pdf/pdf_image.c
+++ b/pdf/pdf_image.c
@@ -69,7 +69,7 @@ typedef struct {
pdf_obj *Mask;
pdf_obj *SMask;
pdf_obj *ColorSpace;
- pdf_obj *Intent;
+ pdf_name *Intent;
pdf_obj *Alternates;
pdf_obj *Name; /* obsolete, do we still support? */
pdf_obj *Decode;
@@ -553,7 +553,7 @@ pdfi_get_image_info(pdf_context *ctx, pdf_dict *image_dict,
/* Optional (default is to use from graphics state) */
/* (no abbreviation for inline) */
- code = pdfi_dict_get(ctx, image_dict, "Intent", &info->Intent);
+ code = pdfi_dict_get_type(ctx, image_dict, "Intent", PDF_NAME, (pdf_obj **)&info->Intent);
if (code < 0) {
if (code != gs_error_undefined)
goto errorExit;
@@ -1174,6 +1174,7 @@ pdfi_do_image(pdf_context *ctx, pdf_dict *page_dict, pdf_dict *stream_dict, pdf_
bool transparency_group = false;
bool has_smask = false;
pdfi_trans_state_t trans_state;
+ int saved_intent;
dbgmprintf(ctx->memory, "pdfi_do_image BEGIN\n");
memset(&mask_info, 0, sizeof(mask_info));
@@ -1188,6 +1189,9 @@ pdfi_do_image(pdf_context *ctx, pdf_dict *page_dict, pdf_dict *stream_dict, pdf_
return code;
}
+ /* Save current rendering intent so we can put it back if it is modified */
+ saved_intent = gs_currentrenderingintent(ctx->pgs);
+
code = pdfi_get_image_info(ctx, image_dict, page_dict, stream_dict, inline_image, &image_info);
if (code < 0)
goto cleanupExit;
@@ -1201,9 +1205,6 @@ pdfi_do_image(pdf_context *ctx, pdf_dict *page_dict, pdf_dict *stream_dict, pdf_
goto cleanupExit;
}
- /* TODO: Save current rendering intent, set it to what is in image, and add a restore in the
- * cleanup of this function (see pdf_draw.ps/doimage) */
-
/* If there is an alternate, swap it in */
/* If image_info.Alternates, look in the array, see if any of them are flagged as "DefaultForPrinting"
* and if so, substitute that one for the image we are processing.
@@ -1230,6 +1231,16 @@ pdfi_do_image(pdf_context *ctx, pdf_dict *page_dict, pdf_dict *stream_dict, pdf_
goto cleanupExit;
}
+ /* Set the rendering intent if applicable */
+ if (image_info.Intent) {
+ code = pdfi_setrenderingintent(ctx, image_info.Intent);
+ if (code < 0) {
+ /* TODO: Flag a warning on this? Sample fts_17_1706.pdf has misspelled Intent
+ which gs renders without flagging an error */
+ dbgmprintf(ctx->memory, "WARNING: Image with unexpected Intent\n");
+ }
+ }
+
/* Get the color for this image */
code = pdfi_image_get_color(ctx, source, &image_info, &comps, &pcs);
if (code < 0)
@@ -1382,6 +1393,9 @@ pdfi_do_image(pdf_context *ctx, pdf_dict *page_dict, pdf_dict *stream_dict, pdf_
if (pcs != NULL)
rc_decrement_only_cs(pcs, "pdfi_do_image");
+ /* Restore the rendering intent */
+ gs_setrenderingintent(ctx->pgs, saved_intent);
+
dbgmprintf(ctx->memory, "pdfi_do_image END\n");
return code;
}
diff --git a/pdf/pdf_misc.c b/pdf/pdf_misc.c
index 92432b4..532e297 100644
--- a/pdf/pdf_misc.c
+++ b/pdf/pdf_misc.c
@@ -105,3 +105,22 @@ pdfi_name_cmp(const pdf_name *n1, const pdf_name *n2)
return -1;
return memcmp(n1->data, n2->data, n1->length);
}
+
+/* Set rendering intent, translating from name to number */
+int pdfi_setrenderingintent(pdf_context *ctx, pdf_name *n)
+{
+ int code = 0;
+
+ if (pdfi_name_is(n, "Perceptual")) {
+ code = gs_setrenderingintent(ctx->pgs, 0);
+ } else if (pdfi_name_is(n, "Saturation")) {
+ code = gs_setrenderingintent(ctx->pgs, 2);
+ } else if (pdfi_name_is(n, "RelativeColorimetric")) {
+ code = gs_setrenderingintent(ctx->pgs, 1);
+ } else if (pdfi_name_is(n, "AbsoluteColorimetric")) {
+ code = gs_setrenderingintent(ctx->pgs, 3);
+ } else {
+ code = gs_error_undefined;
+ }
+ return code;
+}
diff --git a/pdf/pdf_misc.h b/pdf/pdf_misc.h
index ae3a094..20098c6 100644
--- a/pdf/pdf_misc.h
+++ b/pdf/pdf_misc.h
@@ -23,5 +23,6 @@ int pdfi_name_cmp(const pdf_name *n1, const pdf_name *n2);
gs_color_space_index pdfi_get_color_space_index(pdf_context *ctx, const gs_color_space *pcs);
gs_color_space_index pdfi_currentcolorspace(pdf_context *ctx, int index);
+int pdfi_setrenderingintent(pdf_context *ctx, pdf_name *n);
#endif
Summary of changes:
pdf/pdf_colour.c | 12 +-----------
pdf/pdf_gstate.c | 12 +-----------
pdf/pdf_image.c | 24 +++++++++++++++++++-----
pdf/pdf_misc.c | 19 +++++++++++++++++++
pdf/pdf_misc.h | 1 +
5 files changed, 41 insertions(+), 27 deletions(-)