386BSD 0.1 development
[unix-history] / usr / othersrc / public / ghostscript-2.4.1 / gscie.h
CommitLineData
0d4ced25
WJ
1/* Copyright (C) 1992 Aladdin Enterprises. All rights reserved.
2 Distributed by Free Software Foundation, Inc.
3
4This file is part of Ghostscript.
5
6Ghostscript is distributed in the hope that it will be useful, but
7WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
8to anyone for the consequences of using it or for whether it serves any
9particular purpose or works at all, unless he says so in writing. Refer
10to the Ghostscript General Public License for full details.
11
12Everyone is granted permission to copy, modify and redistribute
13Ghostscript, but only under the conditions described in the Ghostscript
14General Public License. A copy of this license is supposed to have been
15given to you along with Ghostscript so you can know your rights and
16responsibilities. It should be in a file named COPYING. Among other
17things, the copyright notice and this notice must be preserved on all
18copies. */
19
20/* gscie.h */
21/* Interface to Ghostscript CIE color algorithms */
22
23/* ------ Common definitions ------ */
24
25/* A 3-element vector. */
26typedef struct gs_vector3_s {
27 float u, v, w;
28} gs_vector3;
29
30/* A 3x3 matrix, stored in column order. */
31typedef struct gs_matrix3_s {
32 gs_vector3 cu, cv, cw;
33} gs_matrix3;
34
35/* A 3-element vector of ranges. */
36typedef struct gs_range_s {
37 float rmin, rmax;
38} gs_range;
39typedef struct gs_range3_s {
40 gs_range u, v, w;
41} gs_range3;
42
43/* A 3-element procedure vector. */
44typedef float (*gs_float_proc)(P1(floatp));
45typedef struct gs_float_proc3_s {
46 gs_float_proc u, v, w;
47} gs_float_proc3;
48
49/* CIE white and black points. */
50typedef 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. */
58typedef 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. */
69typedef 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 */
80extern gs_range3 Range3_default;
81extern gs_float_proc3 Decode3_default;
82extern gs_matrix3 Matrix3_default;
83extern gs_range RangeA_default;
84extern gs_float_proc DecodeA_default;
85extern gs_vector3 MatrixA_default;
86extern gs_vector3 BlackPoint_default;
87
88/* ------ Rendering dictionaries ------ */
89
90typedef struct gs_cie_wbsd_s {
91 struct { gs_vector3 xyz, pqr; } ws, bs, wd, bd;
92} gs_cie_wbsd;
93typedef float (*gs_cie_transform_proc)(P2(gs_cie_wbsd *, floatp));
94typedef 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 */
102typedef 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. */
148extern int gs_cie_abc_decode1(P3(gs_vector3 *pabc, gs_vector3 *ptabc, gs_cie_abc *pcie));
149extern int gs_cie_abc_decode2(P3(gs_vector3 *ptabc, gs_vector3 *ptlmn, gs_cie_abc *pcie));
150extern int gs_cie_abc_decode3(P3(gs_vector3 *ptlmn, gs_vector3 *pxyz, gs_cie_abc *pcie));
151
152/* Decode A value to XYZ. */
153extern int gs_cie_a_decode1(P3(floatp va, float *pta, gs_cie_a *pcie));
154extern 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. */
158extern int gs_cie_render_init(P1(gs_cie_render *pcie));
159
160/* Render CIE colors */
161extern int gs_cie_render_colors1(P5(gs_vector3 *pxyz, gs_cie_wbsd *pwbsd, gs_vector3 *ppqr, gs_cie_wb *points, gs_cie_render *pcie));
162extern int gs_cir_render_colors2(P3(gs_vector3 *ptpqr, gs_vector3 *ptlmn, gs_cie_render *pcie));
163extern int gs_cir_render_colors3(P3(gs_vector3 *ptlmn, gs_vector3 *ptabc, gs_cie_render *pcie));
164extern int gs_cie_render_colors4(P3(gs_vector3 *ptabc, float *colors, gs_cie_render *pcie));