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
|
/* Portions Copyright (C) 2001 artofcode LLC.
Portions Copyright (C) 1996, 2001 Artifex Software Inc.
Portions Copyright (C) 1988, 2000 Aladdin Enterprises.
This software is based in part on the work of the Independent JPEG Group.
All Rights Reserved.
This software is distributed under license and may not be copied, modified
or distributed except as expressly authorized under the terms of that
license. Refer to licensing information at http://www.artifex.com/ or
contact Artifex Software, Inc., 101 Lucas Valley Road #110,
San Rafael, CA 94903, (415)492-9861, for further information. */
/*$Id$ */
/* rtrstst.h - structure for holding raster information in the PCL state */
#ifndef rtrstst_INCLUDED
#define rtrstst_INCLUDED
#include "gsimage.h"
#include "gx.h"
#include "pccoord.h"
/*
* The current state of the raster machinery.
*
* There are several fields in the structure whose presence (or absence) may not
* be totally intuitive.
*
* 1. The graphics margin (the "horizontal" distance of the origin of the image
* from the applicable edge of the logical page) is a state variable, even
* though this fact is almost never apparent in practice. The parameter is
* significant only if "graphics mode" (in the sense used in the PCL
* documentation) is entered implicitly; all of the explicit ways of entering
* graphics mode (<esc>*r#A, where # is in the range 0-3) set the graphics
* margin. Furthermore, if the graphics mode is ended via <esc>*rC (but not
* <esc>*rB), the graphics margin is reset to 0.
*
* For ease of implementation, the graphics margin is in centipoints, but in
* the orientation of raster space. The latter feature is significant: it is
* possible to implicitly enter graphics mode in an orientation different
* from that in which the graphics margin was set. In this case, the
* displacement remains the same, but in a different orientation.
*
* 2. Whether or not raster scaling is (potentially) used for a given image
* is a state variable in some HP PCL implementations, but not in others.
* Speicifically, the DeskJet 1600C/CM never uses raster scaling on implicit
* entry into graphics mode, while the Color LaserJet 5/5M retains the
* state of the last entry into graphics mode (in the current PCL state).
* The latter approach is used in this code.
*
* Note that it is the scale/don't scale value of the last entry into
* graphics mode that is retained, not whether or not scaling actually
* took place for that raster. In particular, assume that graphics mode
* was entered with <esc>*r[23]A but the raster was not scaled due to some
* other condition (palette not writable, source raster dimensions not
* supplied). If the condition preventing raster scaling is altered, and
* subsequently graphics mode entered implicitly, raster scaling will
* occur.
*
* 3. The situation with the scale algorithm feature is not yet clear. The
* documentation states ("PCL 5 Color Technical Reference Manual", May
* 1996 ed., p. 6-42) that "This command is valid only after a Start
* Raster command (<esc>*r#A) with scale mode ON." While this might indicate
* that the scale algorithm is not a state variable, we tend to think the
* statement merely reflects a poor choice of wording. We believe it
* would have been better stated as "this command is not effective except
* after ..." A reason for this belief is that all of the commands that
* are "valid" after a start raster mode are of the form <esc>*b#, while
* the scale algorithm command is of the form <esc>*t#, as are the source
* resolution and destination dimension commands (all of which are state
* variables).
*
* 4. Clipping or rasters in PCL is handled in a manner similar to that of
* text, which leads to some curious behavior. Normally, rasters are clipped
* to the printable page boundary. However, if the raster orgin is at
* the logical page "right" or "bottom" boundary relative to the print
* direction, the raster is clipped completely, even in cases in which the
* logical page boundary is inside the printable region.
*
* Centi-point precision is used to determine whether or not the raster
* origin is at the logical page boundary. For logical orientation 0 and
* 2, the the logical page is either 25 or 21 pixels (at 300 dpi) inside
* the printable region, depending on the page size. Hence, it is possible
* to relocate a raster by one centipoint, and have a 25 pixel extent of
* that raster either appear or disappear.
*
* This clipping is inconsistently applied when presentation mode 3 is
* used and the print direction is not along with width of the "physical"
* page. In this case, the perpendicular of the raster scanline direction
* points in the opposite of the print direction, thus the raster could
* move off the "left" edge of the logical page. No clipping is performed
* in this case, most likely due to the implementation method chosen by HP.
*
* The field clip_all is set to true if the raster output is to be suppressed
* because the raster origin is at the logical page boundary. The motion
* implied by rendered scanlines must still be accounted for, hence the
* need for this field.
*
* Because of the dis-continuous nature of this effect, it is sensitive to
* to arithmetic precision. It is possible to set up situations in practice
* in which the last bit of precision of a floating-point calculation will
* determine whether a raster is clipped or not. Fortunately, these
* situations do not arise in practice.
*/
#ifndef pcl_raster_t_DEFINED
#define pcl_raster_t_DEFINED
typedef struct pcl_raster_t pcl_raster_type;
#endif /* pcl_raster_t_DEFINED */
typedef struct pcl_raster_state_s {
uint resolution; /* source resolution, dots per inch */
/* various flags */
uint pres_mode_3:1; /* 1 ==> presentation mode 3 */
uint scale_raster:1; /* 1 ==> raster scaling enabled */
uint src_width_set:1; /* source raster width explicitly set */
uint src_height_set:1; /* source raster height explicitly set */
uint dest_width_set:1; /* destination width explicitly set */
uint dest_height_set:1; /* destination height explicitly set */
uint scale_algorithm:1; /* not currently supported */
uint graphics_mode:1; /* 1 ==> in graphics mode */
uint compression_mode:8; /* compression mode */
/* for RTL support */
int y_advance; /* advance is +y (1) or -y (-1) */
/* source and (if applicable) destination dimensions */
uint src_width; /* source raster width, samples */
uint src_height; /* source raster height, scanlines */
uint dest_width_cp; /* destination width, centi-points */
uint dest_height_cp; /* destination height, centi-points */
coord gmargin_cp; /* "horizontal" displacement of raster origin */
int clip_all; /* on last entry into raster mode, the raster
* origin was at the logical page edge, hence
* the raster needs to be clipped */
pcl_raster_type *pcur_raster; /* There is at most one image
* actively under construction in PCL
* at one time. This pointer points
* to that image, if it exists. The
* pointer will be non-null while in
* graphic mode. */
} pcl_raster_state_t;
#endif /* rtrstst_INCLUDED */
|