1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gxiparam.h 8803 2008-06-24 14:16:29Z leonardo $ */
15
/* Definitions for implementors of image types */
17
#ifndef gxiparam_INCLUDED
18
# define gxiparam_INCLUDED
20
#include "gsstype.h" /* for extern_st */
23
/* ---------------- Image types ---------------- */
25
/* Define the structure for image types. */
27
#ifndef stream_DEFINED
28
# define stream_DEFINED
29
typedef struct stream_s stream;
32
#ifndef gx_image_type_DEFINED
33
# define gx_image_type_DEFINED
34
typedef struct gx_image_type_s gx_image_type_t;
37
struct gx_image_type_s {
40
* Define the storage type for this type of image.
42
gs_memory_type_ptr_t stype;
45
* Provide the default implementation of begin_typed_image for this
48
dev_proc_begin_typed_image((*begin_typed_image));
51
* Compute the width and height of the source data. For images with
52
* explicit data, this information is in the gs_data_image_t
53
* structure, but ImageType 2 images must compute it.
55
#define image_proc_source_size(proc)\
56
int proc(const gs_imager_state *pis, const gs_image_common_t *pic,\
59
image_proc_source_size((*source_size));
62
* Put image parameters on a stream. Currently this is used
63
* only for banding. If the parameters include a color space,
66
#define image_proc_sput(proc)\
67
int proc(const gs_image_common_t *pic, stream *s,\
68
const gs_color_space **ppcs)
70
image_proc_sput((*sput));
73
* Get image parameters from a stream. Currently this is used
74
* only for banding. If the parameters include a color space,
77
#define image_proc_sget(proc)\
78
int proc(gs_image_common_t *pic, stream *s, gs_color_space *pcs)
80
image_proc_sget((*sget));
83
* Release any parameters allocated by sget.
84
* Currently this only frees the parameter structure itself.
86
#define image_proc_release(proc)\
87
void proc(gs_image_common_t *pic, gs_memory_t *mem)
89
image_proc_release((*release));
92
* We put index last so that if we add more procedures and some
93
* implementor fails to initialize them, we'll get a type error.
95
int index; /* PostScript ImageType */
99
* Define the procedure for getting the source size of an image with
102
image_proc_source_size(gx_data_image_source_size);
104
* Define dummy sput/sget/release procedures for image types that don't
105
* implement these functions.
107
image_proc_sput(gx_image_no_sput); /* rangecheck error */
108
image_proc_sget(gx_image_no_sget); /* rangecheck error */
109
image_proc_release(gx_image_default_release); /* just free the params */
111
* Define sput/sget/release procedures for generic pixel images.
112
* Note that these procedures take different parameters.
114
int gx_pixel_image_sput(const gs_pixel_image_t *pic, stream *s,
115
const gs_color_space **ppcs, int extra);
116
int gx_pixel_image_sget(gs_pixel_image_t *pic, stream *s,
117
gs_color_space *pcs);
118
void gx_pixel_image_release(gs_pixel_image_t *pic, gs_memory_t *mem);
120
/* Internal procedures for use in sput/sget implementations. */
121
bool gx_image_matrix_is_default(const gs_data_image_t *pid);
122
void gx_image_matrix_set_default(gs_data_image_t *pid);
123
void sput_variable_uint(stream *s, uint w);
124
int sget_variable_uint(stream *s, uint *pw);
125
#define DECODE_DEFAULT(i, dd1)\
126
((i) == 1 ? dd1 : (i) & 1)
128
/* ---------------- Image enumerators ---------------- */
130
#ifndef gx_image_enum_common_t_DEFINED
131
# define gx_image_enum_common_t_DEFINED
132
typedef struct gx_image_enum_common_s gx_image_enum_common_t;
136
* Define the procedures associated with an image enumerator.
138
typedef struct gx_image_enum_procs_s {
141
* Pass the next batch of data for processing. *rows_used is set
142
* even in the case of an error.
145
#define image_enum_proc_plane_data(proc)\
146
int proc(gx_image_enum_common_t *info, const gx_image_plane_t *planes,\
147
int height, int *rows_used)
149
image_enum_proc_plane_data((*plane_data));
152
* End processing an image, freeing the enumerator. We keep this
153
* procedure as the last required one, so that we can detect obsolete
154
* static initializers.
157
#define image_enum_proc_end_image(proc)\
158
int proc(gx_image_enum_common_t *info, bool draw_last)
160
image_enum_proc_end_image((*end_image));
163
* Flush any intermediate buffers to the target device.
164
* We need this for situations where two images interact
165
* (currently, only the mask and the data of ImageType 3).
167
* This procedure is optional (may be 0).
170
#define image_enum_proc_flush(proc)\
171
int proc(gx_image_enum_common_t *info)
173
image_enum_proc_flush((*flush));
176
* Determine which data planes should be passed on the next call to the
177
* plane_data procedure, by filling wanted[0 .. num_planes - 1] with 0
178
* for unwanted planes and non-0 for wanted planes. This procedure may
179
* also change the plane_depths[] and/or plane_widths[] values. The
180
* procedure returns true if the returned vector will always be the same
181
* *and* the plane depths and widths remain constant, false if the
182
* wanted planes *or* plane depths or widths may vary over the course of
183
* the image. Note also that the only time a plane's status can change
184
* from wanted to not wanted, and the only time a wanted plane's depth
185
* or width can change, is after a call of plane_data that actually
186
* provides data for that plane.
188
* By default, all data planes are always wanted; however, ImageType 3
189
* images with separate mask and image data sources may want mask data
190
* before image data or vice versa.
192
* This procedure is optional (may be 0).
195
#define image_enum_proc_planes_wanted(proc)\
196
bool proc(const gx_image_enum_common_t *info, byte *wanted)
198
image_enum_proc_planes_wanted((*planes_wanted));
200
} gx_image_enum_procs_t;
203
* Define the common prefix of the image enumerator structure. All
204
* implementations of begin[_typed]_image must initialize all of the members
205
* of this structure, by calling gx_image_enum_common_init and then filling
206
* in whatever else they need to.
208
* Note that the structure includes a unique ID, so that the banding
209
* machinery could in principle keep track of multiple enumerations that may
210
* be in progress simultaneously.
212
#define gx_image_enum_common\
213
const gx_image_type_t *image_type;\
214
const gx_image_enum_procs_t *procs;\
216
gs_memory_t *memory; /* from begin_image */\
218
bool skipping; /* don't render, just consume image streams. */\
220
int plane_depths[GS_IMAGE_MAX_COMPONENTS]; /* [num_planes] */\
221
int plane_widths[GS_IMAGE_MAX_COMPONENTS] /* [num_planes] */
222
struct gx_image_enum_common_s {
223
gx_image_enum_common;
226
extern_st(st_gx_image_enum_common);
227
#define public_st_gx_image_enum_common() /* in gdevddrw.c */\
228
gs_public_st_composite(st_gx_image_enum_common, gx_image_enum_common_t,\
229
"gx_image_enum_common_t",\
230
image_enum_common_enum_ptrs, image_enum_common_reloc_ptrs)
233
* Initialize the common part of an image enumerator.
235
int gx_image_enum_common_init(gx_image_enum_common_t * piec,
236
const gs_data_image_t * pic,
237
const gx_image_enum_procs_t * piep,
238
gx_device * dev, int num_components,
239
gs_image_format_t format);
242
* Define image_plane_data and end_image procedures for image types that
243
* don't have any source data (ImageType 2 and composite images).
245
image_enum_proc_plane_data(gx_no_plane_data);
246
image_enum_proc_end_image(gx_ignore_end_image);
248
* Define the procedures and type data for ImageType 1 images,
249
* which are always included and which are shared with ImageType 4.
251
dev_proc_begin_typed_image(gx_begin_image1);
252
image_enum_proc_plane_data(gx_image1_plane_data);
253
image_enum_proc_end_image(gx_image1_end_image);
254
image_enum_proc_flush(gx_image1_flush);
256
/* Free the image enumerator. */
257
void gx_image_free_enum(gx_image_enum_common_t **ppenum);
259
#endif /* gxiparam_INCLUDED */