1
/* Copyright (C) 2001-2012 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied,
8
modified or distributed except as expressly authorized under the terms
9
of the license contained in the file LICENSE in this distribution.
11
Refer to licensing information at http://www.artifex.com or contact
12
Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
13
CA 94903, U.S.A., +1(415)492-9861, for further information.
17
/* (Distiller) parameter handling for PostScript and PDF writers */
19
#include "jpeglib_.h" /* for sdct.h */
26
#include "strimpl.h" /* for short-sighted compilers */
33
#include "sjbig2_luratech.h"
36
#include "sjpx_luratech.h"
39
/* Define a (bogus) GC descriptor for gs_param_string. */
40
/* The only ones we use are GC-able and not persistent. */
41
gs_private_st_composite(st_gs_param_string, gs_param_string, "gs_param_string",
42
param_string_enum_ptrs, param_string_reloc_ptrs);
44
ENUM_PTRS_WITH(param_string_enum_ptrs, gs_param_string *pstr) return 0;
45
case 0: return ENUM_CONST_STRING(pstr);
48
RELOC_PTRS_WITH(param_string_reloc_ptrs, gs_param_string *pstr)
52
str.data = pstr->data, str.size = pstr->size;
53
RELOC_CONST_STRING_VAR(str);
54
pstr->data = str.data;
57
gs_private_st_element(st_param_string_element, gs_param_string,
58
"gs_param_string[]", param_string_elt_enum_ptrs,
59
param_string_elt_reloc_ptrs, st_gs_param_string);
61
/* ---------------- Get/put Distiller parameters ---------------- */
64
* ColorConversionStrategy is supposed to affect output color space
65
* according to the following table. ****** NOT IMPLEMENTED YET ******
67
PS Input: LeaveCU UseDIC UseDICFI sRGB
68
Gray art Gray CalGray/ICCBased Gray Gray
69
Gray image Gray CalGray/ICCBased CalGray/ICCBased Gray
70
RGB art RGB CalGray/ICCBased RGB CalRGB/sRGB
71
RGB image RGB CalGray/ICCBased CalRGB/ICCBased CalRGB/sRGB
72
CMYK art CMYK LAB/ICCBased CMYK CalRGB/sRGB
73
CMYK image CMYK LAB/ICCBased LAB/ICCBased CalRGB/sRGB
74
CIE art Cal/ICC Cal/ICC Cal/ICC CalRGB/sRGB
75
CIE image Cal/ICC Cal/ICC Cal/ICC CalRGB/sRGB
80
* The Always/NeverEmbed parameters are defined as being incremental. Since
81
* this isn't compatible with the general property of page devices that if
82
* you do a currentpagedevice, doing a setpagedevice later will restore the
83
* same state, we actually define the parameters in sets of 3:
84
* - AlwaysEmbed is used for incremental additions.
85
* - ~AlwaysEmbed is used for incremental deletions.
86
* - .AlwaysEmbed is used for the complete list.
87
* and analogously for NeverEmbed.
90
typedef struct psdf_image_filter_name_s {
92
const stream_template *templat;
93
psdf_version min_version;
94
} psdf_image_filter_name;
96
static const psdf_image_filter_name Poly_filters[] = {
97
{"DCTEncode", &s_DCTE_template},
98
{"FlateEncode", &s_zlibE_template, psdf_version_ll3},
99
{"LZWEncode", &s_LZWE_template},
101
{"JPXEncode", &s_jpxe_template},
106
static const psdf_image_filter_name Mono_filters[] = {
107
{"CCITTFaxEncode", &s_CFE_template},
108
{"FlateEncode", &s_zlibE_template, psdf_version_ll3},
109
{"LZWEncode", &s_LZWE_template},
110
{"RunLengthEncode", &s_RLE_template},
112
{"JBIG2Encode", &s_jbig2encode_template},
117
typedef struct psdf_image_param_names_s {
118
const char *ACSDict; /* not used for mono */
120
const char *DownsampleType;
121
float DownsampleThreshold_default;
122
const psdf_image_filter_name *filter_names;
124
const char *AutoFilterStrategy;
125
gs_param_item_t items[9]; /* AutoFilter (not used for mono), */
127
/* Depth, Downsample, DownsampleThreshold, */
128
/* Encode, Resolution, AutoFilterStrategy, end marker */
129
} psdf_image_param_names_t;
130
#define pi(key, type, memb) { key, type, offset_of(psdf_image_params, memb) }
131
#define psdf_image_param_names(acs, aa, af, de, di, ds, dt, dst, dstd, e, f, fns, r, afs)\
132
acs, di, dt, dstd, fns, f, afs, {\
133
pi(af, gs_param_type_bool, AutoFilter),\
134
pi(aa, gs_param_type_bool, AntiAlias),\
135
pi(de, gs_param_type_int, Depth),\
136
pi(ds, gs_param_type_bool, Downsample),\
137
pi(dst, gs_param_type_float, DownsampleThreshold),\
138
pi(e, gs_param_type_bool, Encode),\
139
pi(r, gs_param_type_int, Resolution),\
140
pi(afs, gs_param_type_int, AutoFilterStrategy),\
144
static const psdf_image_param_names_t Color_names = {
145
psdf_image_param_names(
146
"ColorACSImageDict", "AntiAliasColorImages", "AutoFilterColorImages",
147
"ColorImageDepth", "ColorImageDict",
148
"DownsampleColorImages", "ColorImageDownsampleType",
149
"ColorImageDownsampleThreshold", 1.5,
150
"EncodeColorImages", "ColorImageFilter", Poly_filters,
151
"ColorImageResolution", 0
154
static const psdf_image_param_names_t Gray_names = {
155
psdf_image_param_names(
156
"GrayACSImageDict", "AntiAliasGrayImages", "AutoFilterGrayImages",
157
"GrayImageDepth", "GrayImageDict",
158
"DownsampleGrayImages", "GrayImageDownsampleType",
159
"GrayImageDownsampleThreshold", 2.0,
160
"EncodeGrayImages", "GrayImageFilter", Poly_filters,
161
"GrayImageResolution", 0
164
static const psdf_image_param_names_t Mono_names = {
165
psdf_image_param_names(
166
0, "AntiAliasMonoImages", 0,
167
"MonoImageDepth", "MonoImageDict",
168
"DownsampleMonoImages", "MonoImageDownsampleType",
169
"MonoImageDownsampleThreshold", 2.0,
170
"EncodeMonoImages", "MonoImageFilter", Mono_filters,
171
"MonoImageResolution", 0
174
static const psdf_image_param_names_t Color_names15 = {
175
psdf_image_param_names(
176
"ColorACSImageDict", "AntiAliasColorImages", "AutoFilterColorImages",
177
"ColorImageDepth", "ColorImageDict",
178
"DownsampleColorImages", "ColorImageDownsampleType",
179
"ColorImageDownsampleThreshold", 1.5,
180
"EncodeColorImages", "ColorImageFilter", Poly_filters,
181
"ColorImageResolution", "ColorAutoFilterStrategy"
184
static const psdf_image_param_names_t Gray_names15 = {
185
psdf_image_param_names(
186
"GrayACSImageDict", "AntiAliasGrayImages", "AutoFilterGrayImages",
187
"GrayImageDepth", "GrayImageDict",
188
"DownsampleGrayImages", "GrayImageDownsampleType",
189
"GrayImageDownsampleThreshold", 2.0,
190
"EncodeGrayImages", "GrayImageFilter", Poly_filters,
191
"GrayImageResolution", "GrayAutoFilterStrategy"
195
static const char *const AutoRotatePages_names[] = {
198
static const char *const ColorConversionStrategy_names[] = {
201
static const char *const DownsampleType_names[] = {
204
static const char *const Binding_names[] = {
205
psdf_binding_names, 0
207
static const char *const DefaultRenderingIntent_names[] = {
210
static const char *const TransferFunctionInfo_names[] = {
213
static const char *const UCRandBGInfo_names[] = {
216
static const char *const CannotEmbedFontPolicy_names[] = {
220
static const gs_param_item_t psdf_param_items[] = {
221
#define pi(key, type, memb) { key, type, offset_of(psdf_distiller_params, memb) }
223
/* General parameters */
225
pi("ASCII85EncodePages", gs_param_type_bool, ASCII85EncodePages),
226
/* (AutoRotatePages) */
228
pi("CompressPages", gs_param_type_bool, CompressPages),
229
/* (DefaultRenderingIntent) */
230
pi("DetectBlends", gs_param_type_bool, DetectBlends),
231
pi("DoThumbnails", gs_param_type_bool, DoThumbnails),
232
pi("ImageMemory", gs_param_type_long, ImageMemory),
233
/* (LockDistillerParams) */
234
pi("LZWEncodePages", gs_param_type_bool, LZWEncodePages),
235
pi("OPM", gs_param_type_int, OPM),
236
pi("PreserveHalftoneInfo", gs_param_type_bool, PreserveHalftoneInfo),
237
pi("PreserveOPIComments", gs_param_type_bool, PreserveOPIComments),
238
pi("PreserveOverprintSettings", gs_param_type_bool, PreserveOverprintSettings),
239
/* (TransferFunctionInfo) */
241
pi("UseFlateCompression", gs_param_type_bool, UseFlateCompression),
243
/* Color image processing parameters */
245
pi("ConvertCMYKImagesToRGB", gs_param_type_bool, ConvertCMYKImagesToRGB),
246
pi("ConvertImagesToIndexed", gs_param_type_bool, ConvertImagesToIndexed),
248
/* Font embedding parameters */
250
/* (CannotEmbedFontPolicy) */
251
pi("EmbedAllFonts", gs_param_type_bool, EmbedAllFonts),
252
pi("MaxSubsetPct", gs_param_type_int, MaxSubsetPct),
253
pi("SubsetFonts", gs_param_type_bool, SubsetFonts),
259
/* -------- Get parameters -------- */
262
psdf_write_name(gs_param_list *plist, const char *key, const char *str)
264
gs_param_string pstr;
266
param_string_from_string(pstr, str);
267
return param_write_name(plist, key, &pstr);
271
psdf_write_string_param(gs_param_list *plist, const char *key,
272
const gs_const_string *pstr)
276
ps.data = pstr->data;
277
ps.size = pstr->size;
278
ps.persistent = false;
279
return param_write_string(plist, key, &ps);
283
* Get an image Dict parameter. Note that we return a default (empty)
284
* dictionary if the parameter has never been set.
287
psdf_get_image_dict_param(gs_param_list * plist, const gs_param_name pname,
288
gs_c_param_list *plvalue)
295
dict.size = 12; /* enough for all param dicts we know about */
296
if ((code = param_begin_write_dict(plist, pname, &dict, false)) < 0)
299
gs_c_param_list_read(plvalue);
300
code = param_list_copy(dict.list, (gs_param_list *)plvalue);
302
param_end_write_dict(plist, pname, &dict);
306
/* Get a set of image-related parameters. */
308
psdf_get_image_params(gs_param_list * plist,
309
const psdf_image_param_names_t * pnames, psdf_image_params * params)
311
/* Skip AutoFilter for mono images. */
312
const gs_param_item_t *items =
313
(pnames->items[0].key == 0 ? pnames->items + 1 : pnames->items);
317
* We must actually return a value for every parameter, so that
318
* all parameter names will be recognized as settable by -d or -s
319
* from the command line.
321
code = gs_param_write_items(plist, params, NULL, items);
325
code = psdf_get_image_dict_param(plist, pnames->ACSDict, params->ACSDict);
332
code = psdf_get_image_dict_param(plist, pnames->Dict, params->Dict);
337
code = psdf_write_name(plist, pnames->DownsampleType,
338
DownsampleType_names[params->DownsampleType]);
342
/* (DownsampleThreshold) */
344
code = psdf_write_name(plist, pnames->Filter,
345
(params->Filter == 0 ?
346
pnames->filter_names[0].pname :
353
if (pnames->AutoFilterStrategy != 0)
354
code = psdf_write_name(plist, pnames->AutoFilterStrategy,
355
(params->AutoFilterStrategy == 0 ?
356
"JPEG2000" : params->AutoFilterStrategy));
361
/* Get a font embedding parameter. */
363
psdf_get_embed_param(gs_param_list *plist, gs_param_name allpname,
364
const gs_param_string_array *psa)
366
int code = param_write_name_array(plist, allpname, psa);
369
code = param_write_name_array(plist, allpname + 1, psa);
373
/* Get parameters. */
375
gdev_psdf_get_params(gx_device * dev, gs_param_list * plist)
377
gx_device_psdf *pdev = (gx_device_psdf *) dev;
378
int code = gdev_vector_get_params(dev, plist);
382
code = gs_param_write_items(plist, &pdev->params, NULL, psdf_param_items);
386
/* General parameters */
388
code = psdf_write_name(plist, "AutoRotatePages",
389
AutoRotatePages_names[(int)pdev->params.AutoRotatePages]);
393
code = psdf_write_name(plist, "Binding",
394
Binding_names[(int)pdev->params.Binding]);
398
code = psdf_write_name(plist, "DefaultRenderingIntent",
399
DefaultRenderingIntent_names[(int)pdev->params.DefaultRenderingIntent]);
403
code = psdf_write_name(plist, "TransferFunctionInfo",
404
TransferFunctionInfo_names[(int)pdev->params.TransferFunctionInfo]);
408
code = psdf_write_name(plist, "UCRandBGInfo",
409
UCRandBGInfo_names[(int)pdev->params.UCRandBGInfo]);
413
/* Color sampled image parameters */
415
code = psdf_get_image_params(plist,
416
(pdev->ParamCompatibilityLevel >= 1.5 ? &Color_names15 : &Color_names),
417
&pdev->params.ColorImage);
421
code = psdf_write_name(plist, "ColorConversionStrategy",
422
ColorConversionStrategy_names[(int)pdev->params.ColorConversionStrategy]);
426
code = psdf_write_string_param(plist, "CalCMYKProfile",
427
&pdev->params.CalCMYKProfile);
431
code = psdf_write_string_param(plist, "CalGrayProfile",
432
&pdev->params.CalGrayProfile);
436
code = psdf_write_string_param(plist, "CalRGBProfile",
437
&pdev->params.CalRGBProfile);
441
code = psdf_write_string_param(plist, "sRGBProfile",
442
&pdev->params.sRGBProfile);
446
/* Gray sampled image parameters */
448
code = psdf_get_image_params(plist,
449
(pdev->ParamCompatibilityLevel >= 1.5 ? &Gray_names15 : &Gray_names),
450
&pdev->params.GrayImage);
454
/* Mono sampled image parameters */
456
code = psdf_get_image_params(plist, &Mono_names, &pdev->params.MonoImage);
460
/* Font embedding parameters */
462
code = psdf_get_embed_param(plist, ".AlwaysEmbed", &pdev->params.AlwaysEmbed);
466
code = psdf_get_embed_param(plist, ".NeverEmbed", &pdev->params.NeverEmbed);
470
code = psdf_write_name(plist, "CannotEmbedFontPolicy",
471
CannotEmbedFontPolicy_names[(int)pdev->params.CannotEmbedFontPolicy]);
476
/* -------- Put parameters -------- */
478
extern stream_state_proc_put_params(s_CF_put_params, stream_CF_state);
479
extern stream_state_proc_put_params(s_DCTE_put_params, stream_DCT_state);
480
typedef stream_state_proc_put_params((*ss_put_params_t), stream_state);
483
psdf_read_string_param(gs_param_list *plist, const char *key,
484
gs_const_string *pstr, gs_memory_t *mem, int ecode)
489
switch (code = param_read_string(plist, key, &ps)) {
492
byte *data = gs_alloc_string(mem, size, "psdf_read_string_param");
495
return_error(gs_error_VMerror);
496
memcpy(data, ps.data, size);
510
* The arguments and return value for psdf_put_enum are different because
511
* we must cast the value both going in and coming out.
514
psdf_put_enum(gs_param_list *plist, const char *key, int value,
515
const char *const pnames[], int *pecode)
517
*pecode = param_put_enum(plist, key, &value, pnames, *pecode);
522
psdf_CF_put_params(gs_param_list * plist, stream_state * st)
524
stream_CFE_state *const ss = (stream_CFE_state *) st;
526
(*s_CFE_template.set_defaults) (st);
529
return s_CF_put_params(plist, (stream_CF_state *) ss);
533
psdf_DCT_put_params(gs_param_list * plist, stream_state * st)
535
return psdf_DCT_filter(plist, st, 8 /*nominal*/, 8 /*ibid.*/, 3 /*ibid.*/,
539
/* Put [~](Always|Never)Embed parameters. */
540
/* Returns 0 = OK, 1 = no paramewter specified, <0 = error. */
542
param_read_embed_array(gs_param_list * plist, gs_param_name pname,
543
gs_param_string_array * psa)
547
psa->data = 0, psa->size = 0;
548
switch (code = param_read_name_array(plist, pname, psa)) {
550
param_signal_error(plist, pname, code);
558
param_string_eq(const gs_param_string *ps1, const gs_param_string *ps2)
560
return !bytes_compare(ps1->data, ps1->size, ps2->data, ps2->size);
563
add_embed(gs_param_string_array *prsa, const gs_param_string_array *psa,
567
gs_param_string *const rdata =
568
(gs_param_string *)prsa->data; /* break const */
569
uint count = prsa->size;
571
for (i = 0; i < psa->size; ++i) {
574
for (j = 0; j < count; ++j)
575
if (param_string_eq(&psa->data[i], &rdata[j]))
578
uint size = psa->data[i].size;
579
byte *data = gs_alloc_string(mem, size, "add_embed");
582
return_error(gs_error_VMerror);
583
memcpy(data, psa->data[i].data, size);
584
rdata[count].data = data;
585
rdata[count].size = size;
586
rdata[count].persistent = false;
594
delete_embed(gs_param_string_array *prsa, const gs_param_string_array *pnsa,
598
gs_param_string *const rdata =
599
(gs_param_string *)prsa->data; /* break const */
600
uint count = prsa->size;
602
for (i = pnsa->size; i-- > 0;) {
605
for (j = count; j-- > 0;)
606
if (param_string_eq(&pnsa->data[i], &rdata[j]))
609
gs_free_const_string(mem, rdata[j].data, rdata[j].size,
611
rdata[j] = rdata[--count];
616
static int merge_embed(gs_param_string_array * psa, gs_param_string_array * asa,
619
gs_param_string_array rsa;
620
gs_param_string *rdata;
623
rdata = gs_alloc_struct_array(mem, psa->size + asa->size,
625
&st_param_string_element,
626
"psdf_put_embed_param(update)");
628
return_error(gs_error_VMerror);
629
memcpy(rdata, psa->data, psa->size * sizeof(*psa->data));
631
rsa.size = psa->size;
632
rsa.persistent = false;
633
code = add_embed(&rsa, asa, mem);
635
gs_free_object(mem, rdata, "psdf_put_embed_param(update)");
638
gs_free_const_object(mem, psa->data, "psdf_put_embed_param(free)");
644
psdf_put_embed_param(gs_param_list * plist, gs_param_name notpname,
645
gs_param_name pname, gs_param_string_array * psa,
646
gs_memory_t *mem, int ecode)
648
gs_param_name allpname = pname + 1;
649
gs_param_string_array sa, nsa, asa;
652
mem = gs_memory_stable(mem);
653
code = param_read_embed_array(plist, pname, &sa);
657
/* Optimize for sa == *psa. */
660
if (sa.size == psa->size) {
661
for (i = 0; i < sa.size; ++i) {
662
if (!param_string_eq(&sa.data[i], &psa->data[i]))
670
delete_embed(psa, psa, mem);
671
code = merge_embed(psa, &sa, mem);
676
code = param_read_embed_array(plist, notpname, &nsa);
680
delete_embed(psa, &nsa, mem);
681
code = param_read_embed_array(plist, allpname, &asa);
685
code = merge_embed(psa, &asa, mem);
690
psa->data = gs_resize_object(mem, (gs_param_string *)psa->data, psa->size,
691
"psdf_put_embed_param(resize)");
695
/* Put an image Dict parameter. */
697
psdf_put_image_dict_param(gs_param_list * plist, const gs_param_name pname,
698
gs_c_param_list **pplvalue,
699
const stream_template * templat,
700
ss_put_params_t put_params, gs_memory_t * mem)
703
gs_c_param_list *plvalue = *pplvalue;
706
mem = gs_memory_stable(mem);
707
switch (code = param_begin_read_dict(plist, pname, &dict, false)) {
709
param_signal_error(plist, pname, code);
714
/* Check the parameter values now. */
715
stream_state *ss = s_alloc_state(mem, templat->stype, pname);
718
return_error(gs_error_VMerror);
719
ss->templat = templat;
720
if (templat->set_defaults)
721
templat->set_defaults(ss);
722
code = put_params(dict.list, ss);
723
if (templat->release)
724
templat->release(ss);
725
gs_free_object(mem, ss, pname);
727
param_signal_error(plist, pname, code);
729
plvalue = gs_c_param_list_alloc(mem, pname);
731
return_error(gs_error_VMerror);
732
gs_c_param_list_write(plvalue, mem);
733
code = param_list_copy((gs_param_list *)plvalue,
736
gs_c_param_list_release(plvalue);
737
gs_free_object(mem, plvalue, pname);
742
param_end_read_dict(plist, pname, &dict);
745
if (plvalue != *pplvalue) {
747
gs_c_param_list_release(*pplvalue);
753
/* Put a set of image-related parameters. */
755
psdf_put_image_params(const gx_device_psdf * pdev, gs_param_list * plist,
756
const psdf_image_param_names_t * pnames,
757
psdf_image_params * params, int ecode)
761
* Since this procedure can be called before the device is open,
762
* we must use pdev->memory rather than pdev->v_memory.
764
gs_memory_t *mem = pdev->memory;
766
/* Skip AutoFilter for mono images. */
767
const gs_param_item_t *items =
768
(pnames->items[0].key == 0 ? pnames->items + 1 : pnames->items);
769
int code = gs_param_read_items(plist, params, items);
771
if ((pname = pnames->ACSDict) != 0) {
772
code = psdf_put_image_dict_param(plist, pname, ¶ms->ACSDict,
774
psdf_DCT_put_params, mem);
781
if ((pname = pnames->Dict) != 0) {
782
const stream_template *templat;
783
ss_put_params_t put_params;
785
/* Hack to determine what kind of a Dict we want: */
786
if (pnames->Dict[0] == 'M')
787
templat = &s_CFE_template,
788
put_params = psdf_CF_put_params;
790
templat = &s_DCTE_template,
791
put_params = psdf_DCT_put_params;
792
code = psdf_put_image_dict_param(plist, pname, ¶ms->Dict,
793
templat, put_params, mem);
798
params->DownsampleType = (enum psdf_downsample_type)
799
psdf_put_enum(plist, pnames->DownsampleType,
800
(int)params->DownsampleType, DownsampleType_names,
802
/* (DownsampleThreshold) */
805
/* Process AutoFilterStrategy before Filter, because it sets defaults
807
if (pnames->AutoFilterStrategy != NULL) {
808
switch (code = param_read_string(plist, pnames->AutoFilterStrategy, &fs)) {
811
const psdf_image_filter_name *pn = pnames->filter_names;
812
const char *param_name = 0;
814
if (gs_param_string_eq(&fs, "/JPEG")) {
815
params->AutoFilterStrategy = "/JPEG";
816
param_name = "DCTEncode";
817
} if (gs_param_string_eq(&fs, "/JPEG2000")) {
818
params->AutoFilterStrategy = "/JPEG2000";
819
param_name = "JPXEncode";
821
ecode = gs_error_rangecheck;
824
while (pn->pname != 0 && !gs_param_string_eq(&fs, param_name))
826
if (pn->pname != 0 && pn->min_version <= pdev->version) {
827
params->Filter = pn->pname;
828
params->filter_template = pn->templat;
834
ipe1:param_signal_error(plist, pnames->AutoFilterStrategy, ecode);
840
switch (code = param_read_string(plist, pnames->Filter, &fs)) {
843
const psdf_image_filter_name *pn = pnames->filter_names;
845
while (pn->pname != 0 && !gs_param_string_eq(&fs, pn->pname))
847
if (pn->pname == 0 || pn->min_version > pdev->version) {
848
ecode = gs_error_rangecheck;
851
params->Filter = pn->pname;
852
params->filter_template = pn->templat;
857
ipe:param_signal_error(plist, pnames->Filter, ecode);
862
if (ecode >= 0) { /* Force parameters to acceptable values. */
863
if (params->Resolution < 1)
864
params->Resolution = 1;
865
if (params->DownsampleThreshold < 1 ||
866
params->DownsampleThreshold > 10)
867
params->DownsampleThreshold = pnames->DownsampleThreshold_default;
868
switch (params->Depth) {
882
/* Put parameters. */
884
gdev_psdf_put_params(gx_device * dev, gs_param_list * plist)
886
gx_device_psdf *pdev = (gx_device_psdf *) dev;
888
(pdev->v_memory ? pdev->v_memory : dev->memory);
890
psdf_distiller_params params;
892
params = pdev->params;
895
* If LockDistillerParams was true and isn't being set to false,
896
* ignore all other psdf parameters. However, do not ignore the
897
* standard device parameters.
899
ecode = code = param_read_bool(plist, "LockDistillerParams",
900
¶ms.LockDistillerParams);
901
if (!(pdev->params.LockDistillerParams && params.LockDistillerParams)) {
903
/* General parameters. */
905
code = gs_param_read_items(plist, ¶ms, psdf_param_items);
908
params.AutoRotatePages = (enum psdf_auto_rotate_pages)
909
psdf_put_enum(plist, "AutoRotatePages", (int)params.AutoRotatePages,
910
AutoRotatePages_names, &ecode);
911
params.Binding = (enum psdf_binding)
912
psdf_put_enum(plist, "Binding", (int)params.Binding,
913
Binding_names, &ecode);
914
params.DefaultRenderingIntent = (enum psdf_default_rendering_intent)
915
psdf_put_enum(plist, "DefaultRenderingIntent",
916
(int)params.DefaultRenderingIntent,
917
DefaultRenderingIntent_names, &ecode);
918
params.TransferFunctionInfo = (enum psdf_transfer_function_info)
919
psdf_put_enum(plist, "TransferFunctionInfo",
920
(int)params.TransferFunctionInfo,
921
TransferFunctionInfo_names, &ecode);
922
params.UCRandBGInfo = (enum psdf_ucr_and_bg_info)
923
psdf_put_enum(plist, "UCRandBGInfo", (int)params.UCRandBGInfo,
924
UCRandBGInfo_names, &ecode);
925
ecode = param_put_bool(plist, "UseFlateCompression",
926
¶ms.UseFlateCompression, ecode);
928
/* Color sampled image parameters */
930
ecode = psdf_put_image_params(pdev, plist,
931
(pdev->ParamCompatibilityLevel >= 1.5 ? &Color_names15 : &Color_names),
932
¶ms.ColorImage, ecode);
933
params.ColorConversionStrategy = (enum psdf_color_conversion_strategy)
934
psdf_put_enum(plist, "ColorConversionStrategy",
935
(int)params.ColorConversionStrategy,
936
ColorConversionStrategy_names, &ecode);
937
ecode = psdf_read_string_param(plist, "CalCMYKProfile",
938
¶ms.CalCMYKProfile, mem, ecode);
939
ecode = psdf_read_string_param(plist, "CalGrayProfile",
940
¶ms.CalGrayProfile, mem, ecode);
941
ecode = psdf_read_string_param(plist, "CalRGBProfile",
942
¶ms.CalRGBProfile, mem, ecode);
943
ecode = psdf_read_string_param(plist, "sRGBProfile",
944
¶ms.sRGBProfile, mem, ecode);
946
/* Gray sampled image parameters */
948
ecode = psdf_put_image_params(pdev, plist,
949
(pdev->ParamCompatibilityLevel >= 1.5 ? &Gray_names15 : &Gray_names),
950
¶ms.GrayImage, ecode);
952
/* Mono sampled image parameters */
954
ecode = psdf_put_image_params(pdev, plist, &Mono_names,
955
¶ms.MonoImage, ecode);
957
/* Font embedding parameters */
959
ecode = psdf_put_embed_param(plist, "~AlwaysEmbed", ".AlwaysEmbed",
960
¶ms.AlwaysEmbed, mem, ecode);
961
ecode = psdf_put_embed_param(plist, "~NeverEmbed", ".NeverEmbed",
962
¶ms.NeverEmbed, mem, ecode);
963
params.CannotEmbedFontPolicy = (enum psdf_cannot_embed_font_policy)
964
psdf_put_enum(plist, "CannotEmbedFontPolicy",
965
(int)params.CannotEmbedFontPolicy,
966
CannotEmbedFontPolicy_names, &ecode);
970
code = gdev_vector_put_params(dev, plist);
974
pdev->params = params; /* OK to update now */