1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
/* Copyright (C) 2001-2012 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
implied.
This software is distributed under license and may not be copied,
modified or distributed except as expressly authorized under the terms
of the license contained in the file LICENSE in this distribution.
Refer to licensing information at http://www.artifex.com or contact
Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134, San Rafael,
CA 94903, U.S.A., +1(415)492-9861, for further information.
*/
/* Implementation of color spaces */
/* Requires gsstruct.h */
#ifndef gxcspace_INCLUDED
# define gxcspace_INCLUDED
#include "gscspace.h" /* client interface */
#include "gsccolor.h"
#include "gscsel.h"
#include "gxfrac.h" /* for concrete colors */
#include "gxcindex.h" /* for gx_color_index */
/* Define opaque types. */
#ifndef gx_device_color_DEFINED
# define gx_device_color_DEFINED
typedef struct gx_device_color_s gx_device_color;
#endif
#ifndef gx_device_DEFINED
# define gx_device_DEFINED
typedef struct gx_device_s gx_device;
#endif
#ifndef stream_DEFINED
# define stream_DEFINED
typedef struct stream_s stream;
#endif
/* Color space types (classes): */
/*typedef struct gs_color_space_type_s gs_color_space_type; */
struct gs_color_space_type_s {
gs_color_space_index index;
/*
* Define whether the space can be the base space for an Indexed
* color space or the alternate space for a Separation or DeviceN
* color space.
*/
bool can_be_base_space;
bool can_be_alt_space;
/*
* Define the true structure type for this variant of the color
* space union.
*/
gs_memory_type_ptr_t stype;
/* ------ Procedures ------ */
/*
* Define the number of components in a color of this space. For
* Pattern spaces, where the number of components depends on the
* underlying space, this value is -1 for colored Patterns,
* -N-1 for uncolored Patterns, where N is the number of components
* in the base space.
*/
#define cs_proc_num_components(proc)\
int proc(const gs_color_space *)
#define cs_num_components(pcs)\
(*(pcs)->type->num_components)(pcs)
cs_proc_num_components((*num_components));
/* Construct the initial color value for this space. */
#define cs_proc_init_color(proc)\
void proc(gs_client_color *, const gs_color_space *)
#define cs_init_color(pcc, pcs)\
(*(pcs)->type->init_color)(pcc, pcs)
#define cs_full_init_color(pcc, pcs)\
((pcc)->pattern = 0, cs_init_color(pcc, pcs))
cs_proc_init_color((*init_color));
/* Force a client color into its legal range. */
#define cs_proc_restrict_color(proc)\
void proc(gs_client_color *, const gs_color_space *)
#define cs_restrict_color(pcc, pcs)\
((pcs)->type->restrict_color(pcc, pcs))
cs_proc_restrict_color((*restrict_color));
/* Return the concrete color space underlying this one. */
/* (Not defined for Pattern spaces.) */
#define cs_proc_concrete_space(proc)\
const gs_color_space *proc(const gs_color_space *,\
const gs_imager_state *)
#define cs_concrete_space(pcs, pis)\
(*(pcs)->type->concrete_space)(pcs, pis)
cs_proc_concrete_space((*concrete_space));
/*
* Reduce a color to a concrete color. A concrete color is one
* that the device can handle directly (possibly with halftoning):
* a DeviceGray/RGB/CMYK/Pixel color, or a Separation or DeviceN
* color that does not use the alternate space.
* (Not defined for Pattern spaces.)
*/
#define cs_proc_concretize_color(proc)\
int proc(const gs_client_color *, const gs_color_space *,\
frac *, const gs_imager_state *, gx_device *)
#define cs_concretize_color(pcc, pcs, values, pis, dev)\
(*(pcs)->type->concretize_color)(pcc, pcs, values, pis, dev)
cs_proc_concretize_color((*concretize_color));
/* Map a concrete color to a device color. */
/* (Only defined for concrete color spaces.) */
#define cs_proc_remap_concrete_color(proc)\
int proc(const frac *, const gs_color_space * pcs, gx_device_color *,\
const gs_imager_state *, gx_device *, gs_color_select_t)
cs_proc_remap_concrete_color((*remap_concrete_color));
/* Map a color directly to a device color. */
#define cs_proc_remap_color(proc)\
int proc(const gs_client_color *, const gs_color_space *,\
gx_device_color *, const gs_imager_state *, gx_device *,\
gs_color_select_t)
cs_proc_remap_color((*remap_color));
/* Install the color space in a graphics state. */
#define cs_proc_install_cspace(proc)\
int proc(gs_color_space *, gs_state *)
cs_proc_install_cspace((*install_cspace));
/*
* Push the appropriate overprint compositor onto the current device.
* This is distinct from install_cspace as it may need to be called
* when the overprint parameter is changed.
*
* This routine need only be called if:
* 1. The color space or color model has changed, and overprint
* is true.
* 2. The overprint mode setting has changed, and overprint is true.
* 3. The overprint mode setting has changed.
*/
#define cs_proc_set_overprint(proc)\
int proc(const gs_color_space *, gs_state *)
cs_proc_set_overprint((*set_overprint));
/* Free contents of composite colorspace objects. */
#define cs_proc_final(proc)\
void proc(const gs_color_space *)
cs_proc_final((*final));
/* Adjust reference counts of indirect color components. */
/*
* Note: the color space argument may be NULL, which indicates that the
* caller warrants that any subsidiary colors don't have allocation
* issues. This is a hack for an application that needs to be able to
* release Pattern colors.
*/
#define cs_proc_adjust_color_count(proc)\
void proc(const gs_client_color *, const gs_color_space *, int)
#define cs_adjust_color_count(pgs, delta)\
(*gs_currentcolorspace_inline(pgs)->type->adjust_color_count)\
(gs_currentcolor_inline(pgs), gs_currentcolorspace_inline(pgs), delta)
cs_proc_adjust_color_count((*adjust_color_count));
/* Adjust both reference counts. */
#define cs_adjust_counts(pgs, delta)\
cs_adjust_color_count(pgs, delta); \
rc_adjust_const(gs_currentcolorspace_inline(pgs), delta, "cs_adjust_counts")
/* Serialization. */
/*
* Note : We don't include *(pcs)->type into serialization,
* because we assume it is a static constant to be processed separately.
*/
#define cs_proc_serialize(proc)\
int proc(const gs_color_space *, stream *)
#define cs_serialize(pcs, s)\
(*(pcs)->type->serialize)(pcs, s)
cs_proc_serialize((*serialize));
/* A color mapping linearity check. */
#define cs_proc_is_linear(proc)\
int proc(const gs_color_space *cs, const gs_imager_state * pis,\
gx_device *dev,\
const gs_client_color *c0, const gs_client_color *c1,\
const gs_client_color *c2, const gs_client_color *c3,\
float smoothness, gsicc_link_t *icclink)
#define cs_is_linear(pcs, pis, dev, c0, c1, c2, c3, smoothness, icclink)\
(*(pcs)->type->is_linear)(pcs, pis, dev, c0, c1, c2, c3, smoothness, icclink)
cs_proc_is_linear((*is_linear));
};
extern_st(st_base_color_space);
#define public_st_base_color_space() /* in gscspace.c */\
gs_public_st_simple(st_base_color_space, gs_color_space,\
"gs_base_color_space")
/* Standard color space procedures */
cs_proc_num_components(gx_num_components_1);
cs_proc_num_components(gx_num_components_3);
cs_proc_num_components(gx_num_components_4);
cs_proc_init_color(gx_init_paint_1);
cs_proc_init_color(gx_init_paint_3);
cs_proc_init_color(gx_init_paint_4);
cs_proc_restrict_color(gx_restrict01_paint_1);
cs_proc_restrict_color(gx_restrict01_paint_3);
cs_proc_restrict_color(gx_restrict01_paint_4);
cs_proc_concrete_space(gx_no_concrete_space);
cs_proc_concrete_space(gx_same_concrete_space);
cs_proc_concretize_color(gx_no_concretize_color);
cs_proc_remap_color(gx_default_remap_color);
cs_proc_install_cspace(gx_no_install_cspace);
cs_proc_set_overprint(gx_spot_colors_set_overprint);
cs_proc_adjust_color_count(gx_no_adjust_color_count);
cs_proc_serialize(gx_serialize_cspace_type);
cs_proc_is_linear(gx_cspace_no_linear);
cs_proc_is_linear(gx_cspace_is_linear_default);
/*
* Define the implementation procedures for the standard device color
* spaces. These are implemented in gxcmap.c.
*/
cs_proc_remap_color(gx_remap_DeviceGray);
cs_proc_concretize_color(gx_concretize_DeviceGray);
cs_proc_remap_concrete_color(gx_remap_concrete_DGray);
cs_proc_remap_color(gx_remap_DeviceRGB);
cs_proc_concretize_color(gx_concretize_DeviceRGB);
cs_proc_remap_concrete_color(gx_remap_concrete_DRGB);
cs_proc_remap_color(gx_remap_DeviceCMYK);
cs_proc_concretize_color(gx_concretize_DeviceCMYK);
cs_proc_remap_concrete_color(gx_remap_concrete_DCMYK);
/* Define the allocator type for color spaces. */
extern_st(st_color_space);
/* Allocate a new color space object. Used by color space implementations. */
gs_color_space *
gs_cspace_alloc(gs_memory_t *mem, const gs_color_space_type *pcstype);
/* Determine if the current color model is a "DeviceCMYK" color model, and */
/* if so what are its process color components. Also the same for the RGB */
/* device that simulates CMYK overprinting */
gx_color_index check_cmyk_color_model_comps(gx_device * dev);
gx_color_index check_rgb_color_model_comps(gx_device * dev);
/* Shared code with ICC overprint */
int gx_set_overprint_cmyk(const gs_color_space * pcs, gs_state * pgs);
int gx_set_overprint_rgb(const gs_color_space * pcs, gs_state * pgs);
#endif /* gxcspace_INCLUDED */
|