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