1 /* Copyright (C) 2001-2006 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
7    This software is distributed under license and may not be copied, modified
8    or distributed except as expressly authorized under the terms of that
9    license.  Refer to licensing information at http://www.artifex.com/
10    or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11    San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12 */
13 
14 /* $Id: gscrdp.h 8022 2007-06-05 22:23:38Z giles $ */
15 /* Interface for device-specified CRDs */
16 
17 #ifndef gscrdp_INCLUDED
18 #  define gscrdp_INCLUDED
19 
20 #include "gscie.h"
21 #include "gsparam.h"
22 
23 #ifndef gx_device_DEFINED
24 #  define gx_device_DEFINED
25 typedef struct gx_device_s gx_device;
26 #endif
27 
28 /*
29  * A driver can provide any number of its own CRDs through (read-only)
30  * device parameters whose values are slightly modified PostScript-style
31  * dictionaries.  The driver doesn't need to concern itself with how the
32  * parameters are encoded: it simply constructs a CRD and calls
33  * param_write_cie_render1.
34  *
35  * Logically, the pcrd parameter for this procedure and the next one
36  * should be declared as const gs_cie_render *, but the procedures may
37  * cause certain cached (idempotent) values to be computed.
38  */
39 int param_write_cie_render1(gs_param_list * plist, gs_param_name key,
40 			    gs_cie_render * pcrd,
41 			    gs_memory_t * mem);
42 
43 /*
44  * For internal use, we also provide an API that writes the CRD directly
45  * into a parameter list, rather than as a named parameter in a larger
46  * list.
47  */
48 int param_put_cie_render1(gs_param_list * plist, gs_cie_render * pcrd,
49 			  gs_memory_t * mem);
50 
51 /*
52  * Client code that wants to initialize a CRD from a device parameter
53  * uses the following complementary procedure.  The customary way to
54  * use this is:
55 
56  gs_c_param_list list;
57  ...
58  gs_c_param_list_write(&list, mem);
59  gs_c_param_request(&list, "ParamName");
60  code = gs_getdeviceparams(dev, &list);
61  << error if code < 0 >>
62  gs_c_param_list_read(&list);
63  code = gs_cie_render1_param_initialize(pcrd, &list, "ParamName", dev);
64  gs_c_param_list_release(&list);
65  << error if code < 0 >>
66 
67  * where "ParamName" is the parameter name, e.g., "CRDDefault".
68  */
69 int gs_cie_render1_param_initialize(gs_cie_render * pcrd,
70 				    gs_param_list * plist,
71 				    gs_param_name key,
72 				    gx_device * dev);
73 
74 /*
75  * Again, we provide an internal procedure that doesn't involve a
76  * parameter name.
77  */
78 int param_get_cie_render1(gs_cie_render * pcrd,
79 			  gs_param_list * plist,
80 			  gx_device * dev);
81 
82 /*
83  * The actual representation of the CRD is a slightly modified PostScript
84  * ColorRenderingType 1 dictionary.  THE FOLLOWING IS SUBJECT TO CHANGE
85  * WITHOUT NOTICE.  Specifically, the following keys are different:
86  *      ColorRenderingType = GX_DEVICE_CRD1_TYPE
87  */
88 #define GX_DEVICE_CRD1_TYPE 101
89 /*
90  *      (Instead of TransformPQR = [T1 T2 T3]:)
91  *        TransformPQRName = procedure name (a name)
92  *        TransformPQRData = procedure data (a string)
93  *      (Instead of EncodeLMN/ABC = [E1 E2 E3]:)
94  *        EncodeLMN/ABCValues = [V1,1 V1,2 ... V3,N], where Vi,j is the
95  *          j'th sampled value of the i'th encoding array, mapped linearly
96  *          to the corresponding domain (see gscie.h)
97  *      (Instead of RenderTable = [NA NB NC table m T1 ... Tm]:)
98  *        RenderTableSize = [NA NB NC m]
99  *        RenderTableTable = table (an array of strings)
100  *        RenderTableTValues = [V1,1 V1,2 ... Vm,N] (see above)
101  * The PostScript setcolorrendering operator selects the correct operator
102  * according to the ColorRenderingType key.
103  */
104 
105 #endif /* gscrdp_INCLUDED */
106