summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pcl/pctop.c34
-rw-r--r--pl/plmain.c26
-rw-r--r--pl/plmain.h8
-rw-r--r--pl/pltop.h6
-rw-r--r--pxl/pxtop.c33
-rw-r--r--xps/xpstop.c33
6 files changed, 135 insertions, 5 deletions
diff --git a/pcl/pctop.c b/pcl/pctop.c
index c270196e8..3cd9d3a9b 100644
--- a/pcl/pctop.c
+++ b/pcl/pctop.c
@@ -339,6 +339,36 @@ pcl_get_personality(pl_interp_instance_t *instance, gx_device *device)
return pcl5c;
}
+static int
+pcl_set_icc_params(pl_interp_instance_t *instance, gs_state *pgs)
+{
+ gs_param_string p;
+
+ int code = 0;
+
+ if (instance->pdefault_gray_icc) {
+ param_string_from_transient_string(p, instance->pdefault_gray_icc);
+ code = gs_setdefaultgrayicc(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+
+ if (instance->pdefault_rgb_icc) {
+ param_string_from_transient_string(p, instance->pdefault_rgb_icc);
+ code = gs_setdefaultrgbicc(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+
+ if (instance->piccdir) {
+ param_string_from_transient_string(p, instance->piccdir);
+ code = gs_seticcdirectory(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+ return code;
+}
+
static bool
pcl_get_interpolation(pl_interp_instance_t *instance)
{
@@ -406,6 +436,10 @@ pcl_impl_set_device(
if (code < 0)
goto pisdEnd;
+ code = pcl_set_icc_params(instance, pcli->pcs.pgs);
+ if (code < 0)
+ goto pisdEnd;
+
stage = Sgsave1;
if ( (code = gs_gsave(pcli->pcs.pgs)) < 0 )
goto pisdEnd;
diff --git a/pl/plmain.c b/pl/plmain.c
index 25401ce79..60c66ea43 100644
--- a/pl/plmain.c
+++ b/pl/plmain.c
@@ -725,6 +725,11 @@ pl_main_universe_select(
universe->curr_instance->interpolate = pti->interpolate;
universe->curr_instance->page_set_on_command_line = pti->page_set_on_command_line;
universe->curr_instance->res_set_on_command_line = pti->res_set_on_command_line;
+ universe->curr_instance->piccdir = pti->piccdir;
+ universe->curr_instance->pdefault_gray_icc = pti->pdefault_gray_icc;
+ universe->curr_instance->pdefault_rgb_icc = pti->pdefault_rgb_icc;
+ universe->curr_instance->pdefault_cmyk_icc = pti->pdefault_cmyk_icc;
+
/* Select curr/new device into PDL instance */
if ( pl_set_device(universe->curr_instance, universe->curr_device) < 0 ) {
@@ -794,6 +799,10 @@ pl_main_init_instance(pl_main_instance_t *pti, gs_memory_t *mem)
pti->interpolate = false;
pti->page_set_on_command_line = false;
pti->res_set_on_command_line = false;
+ pti->piccdir = NULL;
+ pti->pdefault_gray_icc = NULL;
+ pti->pdefault_rgb_icc = NULL;
+ pti->pdefault_cmyk_icc = NULL;
strncpy(&pti->pcl_personality[0], "PCL", sizeof(pti->pcl_personality)-1);
}
@@ -1136,7 +1145,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
break;
case 's':
case 'S':
- { /* We're setting a device parameter to a string. */
+ { /* We're setting a device or user parameter to a string. */
char *eqp;
const char *value;
gs_param_string str;
@@ -1151,9 +1160,18 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
pl_top_create_device(pmi,
get_device_index(pmi->memory, value),
false);
- if ( code < 0 ) return code;
- }
- else {
+ if ( code < 0 )
+ return code;
+ /* check for icc settings */
+ } else if (!strncmp(arg, "DefaultGrayProfile", strlen("DefaultGrayProfile"))) {
+ pmi->pdefault_gray_icc = arg_heap_copy(value);
+ } else if (!strncmp(arg, "DefaultRGBProfile", strlen("DefaultRGBProfile"))) {
+ pmi->pdefault_rgb_icc = arg_heap_copy(value);
+ } else if (!strncmp(arg, "DefaultCMYKProfile", strlen("DefaultCMYKProfile"))) {
+ pmi->pdefault_cmyk_icc = arg_heap_copy(value);
+ } else if (!strncmp(arg, "ICCProfileDir", strlen("ICCProfileDir"))) {
+ pmi->piccdir = arg_heap_copy(value);
+ } else {
char buffer[128];
strncpy(buffer, arg, eqp - arg);
buffer[eqp - arg] = '\0';
diff --git a/pl/plmain.h b/pl/plmain.h
index d29c14e30..e99aa9bfd 100644
--- a/pl/plmain.h
+++ b/pl/plmain.h
@@ -19,6 +19,7 @@
#include "gsargs.h"
#include "gsgc.h"
+
/*
* Define the parameters for running the interpreter.
*/
@@ -55,6 +56,13 @@ typedef struct pl_main_instance_s {
bool interpolate;
bool page_set_on_command_line;
bool res_set_on_command_line;
+
+ /* we have to store these in the main instance until the languages
+ state is sufficiently initialized to set the parameters. */
+ char *piccdir;
+ char *pdefault_gray_icc;
+ char *pdefault_rgb_icc;
+ char *pdefault_cmyk_icc;
} pl_main_instance_t;
/* initialize gs_stdin, gs_stdout, and gs_stderr. Eventually the gs
diff --git a/pl/pltop.h b/pl/pltop.h
index 831d2aae7..8493398b5 100644
--- a/pl/pltop.h
+++ b/pl/pltop.h
@@ -37,12 +37,16 @@ typedef struct pl_interp_s {
} pl_interp_t;
typedef struct pl_interp_instance_s {
- pl_interp_t *interp; /* interpreter instance refers to */
+ pl_interp_t* interp; /* interpreter instance refers to */
vm_spaces spaces; /* spaces for GC */
char * pcl_personality;
bool interpolate;
bool page_set_on_command_line;
bool res_set_on_command_line;
+ char * piccdir;
+ char * pdefault_gray_icc;
+ char * pdefault_rgb_icc;
+ char * pdefault_cmyk_icc;
} pl_interp_instance_t;
/* Param data types */
diff --git a/pxl/pxtop.c b/pxl/pxtop.c
index 55319bafc..062cf51a7 100644
--- a/pxl/pxtop.c
+++ b/pxl/pxtop.c
@@ -297,6 +297,35 @@ pxl_impl_set_post_page_action(
return 0;
}
+static int
+pxl_set_icc_params(pl_interp_instance_t *instance, gs_state *pgs)
+{
+ gs_param_string p;
+ int code = 0;
+
+ if (instance->pdefault_gray_icc) {
+ param_string_from_transient_string(p, instance->pdefault_gray_icc);
+ code = gs_setdefaultgrayicc(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+
+ if (instance->pdefault_rgb_icc) {
+ param_string_from_transient_string(p, instance->pdefault_rgb_icc);
+ code = gs_setdefaultrgbicc(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+
+ if (instance->piccdir) {
+ param_string_from_transient_string(p, instance->piccdir);
+ code = gs_seticcdirectory(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+ return code;
+}
+
static bool
pxl_get_interpolation(pl_interp_instance_t *instance)
{
@@ -335,6 +364,10 @@ pxl_impl_set_device(
if ((code = px_initgraphics(pxli->pxs)) < 0)
goto pisdEnd;
+ code = pxl_set_icc_params(instance, pxli->pgs);
+ if (code < 0)
+ goto pisdEnd;
+
/* Do inits of gstate that may be reset by setdevice */
gs_setaccuratecurves(pxli->pgs, true); /* All H-P languages want accurate curves. */
/* disable hinting at high res */
diff --git a/xps/xpstop.c b/xps/xpstop.c
index 3effd01ac..1538b9ce2 100644
--- a/xps/xpstop.c
+++ b/xps/xpstop.c
@@ -81,6 +81,38 @@ xps_imp_allocate_interp(pl_interp_t **ppinterp,
return 0;
}
+static int
+xps_set_icc_user_params(pl_interp_instance_t *instance, gs_state *pgs)
+{ gs_param_string p;
+ int code = 0;
+
+ if (instance->pdefault_gray_icc) {
+ param_string_from_transient_string(p, instance->pdefault_gray_icc);
+ code = gs_setdefaultgrayicc(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+ if (instance->pdefault_rgb_icc) {
+ param_string_from_transient_string(p, instance->pdefault_rgb_icc);
+ code = gs_setdefaultrgbicc(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+ if (instance->pdefault_cmyk_icc) {
+ param_string_from_transient_string(p, instance->pdefault_cmyk_icc);
+ code = gs_setdefaultcmykicc(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+ if (instance->piccdir) {
+ param_string_from_transient_string(p, instance->piccdir);
+ code = gs_seticcdirectory(pgs, &p);
+ if (code < 0)
+ return gs_throw_code(gs_error_Fatal);
+ }
+ return code;
+}
+
/* Do per-instance interpreter allocation/init. No device is set yet */
static int
xps_imp_allocate_interp_instance(pl_interp_instance_t **ppinstance,
@@ -145,6 +177,7 @@ xps_imp_allocate_interp_instance(pl_interp_instance_t **ppinstance,
gs_setaligntopixels(ctx->fontdir, 1); /* no subpixels */
gs_setgridfittt(ctx->fontdir, 1); /* see gx_ttf_outline in gxttfn.c for values */
+ (void)xps_set_icc_user_params((pl_interp_instance_t *)instance, ctx->pgs);
*ppinstance = (pl_interp_instance_t *)instance;
return 0;