xref: /plan9/sys/src/cmd/gs/src/gscssub.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 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: gscssub.h,v 1.5 2002/06/16 08:45:42 lpd Exp $ */
18 /* Client interface to color space substitution */
19 
20 #ifndef gscssub_INCLUDED
21 #  define gscssub_INCLUDED
22 
23 #include "gscspace.h"
24 
25 /*
26  * Color space substitution at the library level is similar to, but not
27  * identical to, the operation of UseCIEColor in the PostScript language.
28  * When the Boolean UseCIEColor parameter of the current device is false,
29  * everything operates as normal.  When UseCIEColor is true, the following
30  * procedures may substitute another color space for the implied one:
31  *
32  *	gs_setgray, gs_setrgbcolor, gs_sethsbcolor, gs_setcmykcolor
33  *	gs_current_Device{Gray,RGB,CMYK}_space
34  *
35  * Unlike the PostScript facility, the substitution *is* visible to
36  * gs_currentcolorspace, and does *not* affect gs_setcolorspace, or the
37  * ColorSpace members of images or shadings.  However, the following
38  * procedures recognize when substitution has occurred and return the
39  * value(s) appropriate for the pre-substitution space:
40  *
41  *	gs_currentgray, gs_currentrgbcolor, gs_currenthsbcolor,
42  *	  gs_currentcmykcolor
43  *
44  * Thus gs_{current,set}{gray,{rgb,hsb,cmyk}color} are always mutually
45  * consistent, concealing any substitution, and gs_{current,set}{colorspace}
46  * are mutually consistent, reflecting any substitution.
47  * gs_{current,set}color are consistent with the other color accessors,
48  * since color space substitution doesn't affect color values.
49  *
50  * As in PostScript, color space substitutions are not affected by
51  * (ordinary) grestore or by setgstate.  Graphics states created by gsave or
52  * gstate, or overwritten by currentgstate or copygstate, share
53  * substitutions with the state from which they were copied.
54  */
55 
56 /* If pcs is NULL, it means undo any substitution. */
57 int gs_setsubstitutecolorspace(gs_state *pgs, gs_color_space_index csi,
58 			       const gs_color_space *pcs);
59 const gs_color_space *
60     gs_currentsubstitutecolorspace(const gs_state *pgs,
61 				   gs_color_space_index csi);
62 
63 /*
64  * The following procedures are primarily for internal use, to provide
65  * fast access to specific color spaces.
66  */
67 const gs_color_space *gs_current_DeviceGray_space(const gs_state *pgs);
68 const gs_color_space *gs_current_DeviceRGB_space(const gs_state *pgs);
69 const gs_color_space *gs_current_DeviceCMYK_space(const gs_state *pgs);
70 
71 #endif /* gscssub_INCLUDED */
72