[gs-commits] ghostpdl branch, pdfi, updated. jbig2dec-0.14-2201-gc6aca0d

[email protected] (Nancy Durgin)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, pdfi has been updated
       via  c6aca0db1566705920766c94a821a4fa08c7ea23 (commit)
      from  ff35f1a2d576d6f5fa04b2279672a1a8d901af3b (commit)

----------------------------------------------------------------------
commit c6aca0db1566705920766c94a821a4fa08c7ea23
Author: Nancy Durgin <[email protected]>
Date:   Thu Sep 5 10:56:12 2019 -0700

    Fix "okOPcs" implementation for transparency
    
    Add utility funcs to get the colorspace index
    Implement pdfi_trans_okOPcs correctly
    
    NOTE: The gs implementation includes DeviceGray as a colorspace that
    supports OP, but this isn't what spec (pdf1.7 pg 259,578) says.  Maybe
    there is a subtle reason to include it?  Leaving it out for now.

diff --git a/pdf/pdf_misc.c b/pdf/pdf_misc.c
index 02e8bdf..92432b4 100644
--- a/pdf/pdf_misc.c
+++ b/pdf/pdf_misc.c
@@ -44,6 +44,42 @@ int pdfi_get_current_bbox(pdf_context *ctx, gs_rect *bbox, bool stroked)
     return code;
 }
 
+/* Get the current color space (the base one) from a color space
+ */
+gs_color_space_index pdfi_get_color_space_index(pdf_context *ctx, const gs_color_space *pcs)
+{
+    gs_color_space_index csi;
+
+    /* Get the color space index */
+    csi = gs_color_space_get_index(pcs);
+
+    /* If its an Indexed space, then use the base space */
+    if (csi == gs_color_space_index_Indexed)
+        csi = gs_color_space_get_index(pcs->base_space);
+
+    /* If its ICC, see if its a substitution for one of the device
+     * spaces. If so then we will want to behave as if we were using the
+     * device space.
+     */
+    if (csi == gs_color_space_index_ICC)
+        csi = gsicc_get_default_type(pcs->cmm_icc_profile_data);
+
+    return csi;
+}
+
+/* Get the current color space (the base one) from current graphics state.
+ * index -- tells whether to pull from 0 or 1 (probably 0)
+ */
+gs_color_space_index pdfi_currentcolorspace(pdf_context *ctx, int index)
+{
+    const gs_color_space *pcs;
+
+    pcs = ctx->pgs->color[index].color_space;
+
+    return pdfi_get_color_space_index(ctx, pcs);
+}
+
+
 int
 pdfi_name_strcmp(const pdf_name *n, const char *s)
 {
diff --git a/pdf/pdf_misc.h b/pdf/pdf_misc.h
index a10f6ed..ae3a094 100644
--- a/pdf/pdf_misc.h
+++ b/pdf/pdf_misc.h
@@ -21,4 +21,7 @@ int pdfi_name_strcmp(const pdf_name *n, const char *s);
 bool pdfi_name_is(const pdf_name *n, const char *s);
 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);
+
 #endif
diff --git a/pdf/pdf_trans.c b/pdf/pdf_trans.c
index 5bf4958..91d361b 100644
--- a/pdf/pdf_trans.c
+++ b/pdf/pdf_trans.c
@@ -432,12 +432,32 @@ void pdfi_trans_set_needs_OP(pdf_context *ctx)
                 "NEEDS" : "does NOT NEED");
 }
 
-/* Figures out if current colorspace is okay for Overprint */
+/* Figures out if current colorspace is okay for Overprint (see pdf_ops.ps/okOPcs and setupOPtrans) */
 static bool pdfi_trans_okOPcs(pdf_context *ctx)
 {
-    /* TODO: Need to figure out insane pdf colorspace stuff */
-    /* See pdf_ops.ps/okOPcs , /setupOPtrans */
-    return true;
+    gs_color_space_index csi;
+
+    csi = pdfi_currentcolorspace(ctx, 0);
+
+    switch (csi) {
+#if 0 /* TODO? */
+    case gs_color_space_index_DeviceGray:
+#endif
+    case gs_color_space_index_DeviceCMYK:
+    case gs_color_space_index_DeviceN:
+    case gs_color_space_index_Separation:
+        /* These are colorspaces that don't require special handling for overprint.
+         * (pdf1.7 pg 259,578 may apply)
+         * TODO: Unclear if DeviceGray should be included?  Mvrhel says it shouldn't be (9-5-19)
+         */
+        dbgmprintf1(ctx->memory, "Colorspace is %d, OKAY for OVERPRINT\n", csi);
+        return true;
+    default:
+        dbgmprintf1(ctx->memory, "Colorspace is %d, NOT OKAY for OVERPRINT\n", csi);
+        return false;
+    }
+
+    return false;
 }
 
 int pdfi_trans_setup(pdf_context *ctx, pdfi_trans_state_t *state,


Summary of changes:
 pdf/pdf_misc.c  | 36 ++++++++++++++++++++++++++++++++++++
 pdf/pdf_misc.h  |  3 +++
 pdf/pdf_trans.c | 28 ++++++++++++++++++++++++----
 3 files changed, 63 insertions(+), 4 deletions(-)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.