Commit | Line | Data |
---|---|---|
0d4ced25 WJ |
1 | /* Copyright (C) 1992 Aladdin Enterprises. All rights reserved. |
2 | Distributed by Free Software Foundation, Inc. | |
3 | ||
4 | This file is part of Ghostscript. | |
5 | ||
6 | Ghostscript is distributed in the hope that it will be useful, but | |
7 | WITHOUT ANY WARRANTY. No author or distributor accepts responsibility | |
8 | to anyone for the consequences of using it or for whether it serves any | |
9 | particular purpose or works at all, unless he says so in writing. Refer | |
10 | to the Ghostscript General Public License for full details. | |
11 | ||
12 | Everyone is granted permission to copy, modify and redistribute | |
13 | Ghostscript, but only under the conditions described in the Ghostscript | |
14 | General Public License. A copy of this license is supposed to have been | |
15 | given to you along with Ghostscript so you can know your rights and | |
16 | responsibilities. It should be in a file named COPYING. Among other | |
17 | things, the copyright notice and this notice must be preserved on all | |
18 | copies. */ | |
19 | ||
20 | /* gscie.h */ | |
21 | /* Interface to Ghostscript CIE color algorithms */ | |
22 | ||
23 | /* ------ Common definitions ------ */ | |
24 | ||
25 | /* A 3-element vector. */ | |
26 | typedef struct gs_vector3_s { | |
27 | float u, v, w; | |
28 | } gs_vector3; | |
29 | ||
30 | /* A 3x3 matrix, stored in column order. */ | |
31 | typedef struct gs_matrix3_s { | |
32 | gs_vector3 cu, cv, cw; | |
33 | } gs_matrix3; | |
34 | ||
35 | /* A 3-element vector of ranges. */ | |
36 | typedef struct gs_range_s { | |
37 | float rmin, rmax; | |
38 | } gs_range; | |
39 | typedef struct gs_range3_s { | |
40 | gs_range u, v, w; | |
41 | } gs_range3; | |
42 | ||
43 | /* A 3-element procedure vector. */ | |
44 | typedef float (*gs_float_proc)(P1(floatp)); | |
45 | typedef struct gs_float_proc3_s { | |
46 | gs_float_proc u, v, w; | |
47 | } gs_float_proc3; | |
48 | ||
49 | /* CIE white and black points. */ | |
50 | typedef struct gs_cie_wb_s { | |
51 | gs_vector3 WhitePoint; | |
52 | gs_vector3 BlackPoint; | |
53 | } gs_cie_wb; | |
54 | ||
55 | /* ------ Color space dictionaries ------ */ | |
56 | ||
57 | /* A CIEBasedABC dictionary. */ | |
58 | typedef struct gs_cie_abc_s { | |
59 | gs_range3 RangeABC; | |
60 | gs_float_proc3 DecodeABC; | |
61 | gs_matrix3 MatrixABC; | |
62 | gs_range3 RangeLMN; | |
63 | gs_float_proc3 DecodeLMN; | |
64 | gs_matrix3 MatrixLMN; | |
65 | gs_cie_wb points; | |
66 | } gs_cie_abc; | |
67 | ||
68 | /* A CIEBasedA dictionary. */ | |
69 | typedef struct gs_cie_a_s { | |
70 | gs_range RangeA; | |
71 | gs_float_proc DecodeA; | |
72 | gs_vector3 MatrixA; | |
73 | gs_range3 RangeLMN; | |
74 | gs_float_proc3 DecodeLMN; | |
75 | gs_matrix3 MatrixLMN; | |
76 | gs_cie_wb points; | |
77 | } gs_cie_a; | |
78 | ||
79 | /* Default values for components */ | |
80 | extern gs_range3 Range3_default; | |
81 | extern gs_float_proc3 Decode3_default; | |
82 | extern gs_matrix3 Matrix3_default; | |
83 | extern gs_range RangeA_default; | |
84 | extern gs_float_proc DecodeA_default; | |
85 | extern gs_vector3 MatrixA_default; | |
86 | extern gs_vector3 BlackPoint_default; | |
87 | ||
88 | /* ------ Rendering dictionaries ------ */ | |
89 | ||
90 | typedef struct gs_cie_wbsd_s { | |
91 | struct { gs_vector3 xyz, pqr; } ws, bs, wd, bd; | |
92 | } gs_cie_wbsd; | |
93 | typedef float (*gs_cie_transform_proc)(P2(gs_cie_wbsd *, floatp)); | |
94 | typedef struct gs_cie_render_table_s { | |
95 | int NA, NB, NC; /* >1 */ | |
96 | byte **table; /* [NA][m * NB * NC] */ | |
97 | /* 0 means no table */ | |
98 | int m; /* 3 or 4 */ | |
99 | gs_float_proc T[4]; /* [m] */ | |
100 | } gs_cie_render_table; | |
101 | /* The main dictionary */ | |
102 | typedef struct gs_cie_render_s { | |
103 | gs_matrix3 MatrixLMN; | |
104 | gs_float_proc3 EncodeLMN; | |
105 | gs_range3 RangeLMN; | |
106 | gs_matrix3 MatrixABC; | |
107 | gs_float_proc3 EncodeABC; | |
108 | gs_range3 RangeABC; | |
109 | gs_cie_wb points; | |
110 | gs_matrix3 MatrixPQR; | |
111 | gs_range3 RangePQR; | |
112 | struct { gs_cie_transform_proc u, v, w; } TransformPQR; | |
113 | gs_cie_render_table RenderTable; | |
114 | /* Following are computed when table is initialized. */ | |
115 | gs_matrix3 MatrixPQR_inverse; | |
116 | gs_vector3 wdpqr, bdpqr; | |
117 | } gs_cie_render; | |
118 | ||
119 | /* ------ Procedures ------ */ | |
120 | ||
121 | /* | |
122 | * The decoding and rendering algorithms involve user-defined procedures. | |
123 | * Since the interpreter handles these specially, the algorithms *return* | |
124 | * to the caller between steps, rather than using a call-back. | |
125 | * The scenario for decoding: | |
126 | * gs_cie_abc_decode1(abc, tabc) | |
127 | * ... DecodeABC(tabc) ... | |
128 | * gs_cie_abc_decode2(tabc, tlmn) | |
129 | * ... DecodeLMN(tlmn) ... | |
130 | * gs_cie_abc_decode3(tlmn, xyz) | |
131 | * or: | |
132 | * gs_cie_a_decode1(a, ta) | |
133 | * ... DecodeA(ta) ... | |
134 | * gs_cie_a_decode2(ta, tlmn) | |
135 | * ... DecodeLMN(tlmn) ... | |
136 | * gs_cie_a_decode3(tlmn, xyz) [same as abc_decode3] | |
137 | * The scenario for rendering: | |
138 | * gs_cie_render_colors1(xyz, wbsd, tpqr) | |
139 | * ... TransformPQR(wbsd, tpqr) ... | |
140 | * gs_cie_render_colors2(tpqr, tlmn) | |
141 | * ... EncodeLMN(tlmn) ... | |
142 | * gs_cie_render_colors3(tlmn, tabc) | |
143 | * ... EncodeABC(tabc) ... | |
144 | * gs_cie_render_colors4(tabc, colors) | |
145 | */ | |
146 | ||
147 | /* Decode ABC values to XYZ. */ | |
148 | extern int gs_cie_abc_decode1(P3(gs_vector3 *pabc, gs_vector3 *ptabc, gs_cie_abc *pcie)); | |
149 | extern int gs_cie_abc_decode2(P3(gs_vector3 *ptabc, gs_vector3 *ptlmn, gs_cie_abc *pcie)); | |
150 | extern int gs_cie_abc_decode3(P3(gs_vector3 *ptlmn, gs_vector3 *pxyz, gs_cie_abc *pcie)); | |
151 | ||
152 | /* Decode A value to XYZ. */ | |
153 | extern int gs_cie_a_decode1(P3(floatp va, float *pta, gs_cie_a *pcie)); | |
154 | extern int gs_cie_a_decode2(P3(floatp ta, gs_vector3 *ptlmn, gs_cie_a *pcie)); | |
155 | #define gs_cie_a_decode3(ptlmn, pxyz, pcie) gs_cie_abc_decode3(ptlmn, pxyz, pcie) | |
156 | ||
157 | /* Compute the cached values in a CIE rendering table. */ | |
158 | extern int gs_cie_render_init(P1(gs_cie_render *pcie)); | |
159 | ||
160 | /* Render CIE colors */ | |
161 | extern int gs_cie_render_colors1(P5(gs_vector3 *pxyz, gs_cie_wbsd *pwbsd, gs_vector3 *ppqr, gs_cie_wb *points, gs_cie_render *pcie)); | |
162 | extern int gs_cir_render_colors2(P3(gs_vector3 *ptpqr, gs_vector3 *ptlmn, gs_cie_render *pcie)); | |
163 | extern int gs_cir_render_colors3(P3(gs_vector3 *ptlmn, gs_vector3 *ptabc, gs_cie_render *pcie)); | |
164 | extern int gs_cie_render_colors4(P3(gs_vector3 *ptabc, float *colors, gs_cie_render *pcie)); |