1 /* pdapi.h -- PDAPI������ե�����
2  * Copyright (C) 2003 EPSON KOWA Corporation
3  *
4  * Permission to use, copy, modify, distribute, and sell this software
5  * and its documentation for any purpose is hereby granted without fee,
6  * provided that the above copyright notice appear in all copies and
7  * that both that copyright notice and this permission notice appear in
8  * supporting documentation.
9  *
10  * The above copyright notice and this permission notice shall be
11  * included in all copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
16  * NONINFRINGEMENT.  IN NO EVENT SHALL EPSON KOWA CORPORATION BE LIABLE FOR
17  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
18  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20  *
21  * Except as contained in this notice, the name of EPSON KOWA Corporation
22  * shall not be used in advertising or otherwise to promote the sale,
23  * use or other dealings in this Software without prior written
24  * authorization from EPSON KOWA Corporation.
25  */
26 
27 /* $Id: pdapi.h,v 1.1.1.1 2004/10/22 08:37:09 gishi Exp $ */
28 
29 #ifndef _PDAPI_H
30 #define _PDAPI_H
31 
32 /* Return Values */
33 #define	OK		0
34 #define ERROR		-1
35 
36 /* Error Codes */
37 /*
38  * ����γ��ͤϲ���
39  */
40 #define	FATALERROR	1	/* �饤�֥����������Բ�ǽ�ʥ��顼��ȯ������ */
41 #define	BADREQUEST	2	/* �ؿ���Ƥ�ǤϤ����ʤ��Ȥ���ǡ��Ƥ�Ǥ��ޤä� */
42 #define	BADCONTEXT	3	/* �ѥ�᡼���Υץ������ƥ����Ȥ����� */
43 #define	NOTSUPPORTED	4	/* �ѥ�᡼�����Ȥ߹�碌�ˤ�ꡢ�ɥ饤�Ф⤷����
44 				   �ץ���������ʤ��ꥯ�����Ȥ��Ԥ�줿��*/
45 #define	JOBCANCELED	5	/* �ʤ�餫���װ��ˤ�ꡢ����֤�����뤷�Ƥ��롣*/
46 #define	PARAMERROR	6	/* �ѥ�᡼�����Ȥ߹�碌������ */
47 
48 
49 /* Fix  */
50 /**
51  * opvp_common.h���饳�ԡ�����OPVP_����
52  */
53 #define FIX_FRACT_WIDTH    8
54 #define FIX_FRACT_DENOM    (1<<FIX_FRACT_WIDTH)
55 #define FIX_FLOOR_WIDTH    (sizeof(int)*8-FIX_FRACT_WIDTH)
56 typedef struct {
57         unsigned int    fract   : FIX_FRACT_WIDTH;
58         signed int      floor   : FIX_FLOOR_WIDTH;
59 } Fix;
60 #define i2Fix(i,fix)       (fix.fract=0,fix.floor=i)
61 #define Fix2f(fix,f)       (f=(double)fix.floor\
62                                   +(double)(fix.fract)/FIX_FRACT_DENOM)
63 #define f2Fix(f,fix)       (fix.fract=(f-floor(f))*FIX_FRACT_DENOM,\
64                                  fix.floor=floor(f))
65 /* �ڤ�Τƥ����� */
66 /* #define Fix2i(fix)         (fix.floor) */
67 /* �ͼθ��������� */
68 #define Fix2i(fix)         (fix.floor + (int)floor(((double)(fix.fract) / FIX_FRACT_DENOM) + 0.5))
69 #define Fix2d(fix)       ((double)fix.floor + (double)(fix.fract) / FIX_FRACT_DENOM)
70 #define ApplyCtmX_Integer(x, y, ctm) ((int)(floor(((Fix2d(x) * (ctm).a) + (Fix2d(y) * (ctm).c) + (ctm).e) + 0.5)))
71 #define ApplyCtmY_Integer(x, y, ctm) ((int)(floor(((Fix2d(x) * (ctm).b) + (Fix2d(y) * (ctm).d) + (ctm).f) + 0.5)))
72 
73 /** �����ޤ� */
74 
75 
76 /* Basic Types */
77 typedef struct Point_s {
78 	Fix	x;
79 	Fix	y;
80 } Point;
81 
82 typedef struct Rectangle_s {
83 	Point	p0;	/* ������ */
84 	Point	p1;	/* �г��� */
85 } Rectangle;
86 
87 typedef struct RoundRectangle_s {
88 	Point	p0;	/* ������ */
89 	Point	p1;	/* �г��� */
90 	Fix		xellipse;
91 	Fix		yellipse;
92 } RoundRectangle;
93 
94 /* Image Formats */
95 typedef enum _ImageFormat {
96 	iformatRaw = 0,
97 	iformatRLE = 1,
98 	iformatJPEG = 2,
99 	iformatPNG = 3
100 } ImageFormat;
101 
102 /* Color Presentation */
103 typedef enum _ColorMapping {
104 	cmapDirect = 0,
105 	cmapIndexed = 1
106 } ColorMapping;
107 
108 typedef enum _ColorSpace {
109 	cspaceBW = 0,
110 	cspaceDeviceGray = 1,
111 	cspaceDeviceCMY = 2,
112 	cspaceDeviceCMYK = 3,
113 	cspaceDeviceRGB = 4,
114 	cspaceStandardRGB = 5,
115 	cspaceStandardRGB64 = 6
116 } ColorSpace;
117 
118 /* Fill, Paint, Clip */
119 typedef enum _FillMode {
120 	fillModeEvenOdd = 0,
121 	fillModeWinding = 1
122 } FillMode;
123 
124 typedef enum _PaintMode {
125 	paintModeOpaque = 0,
126 	paintModeTransparent = 1
127 } PaintMode;
128 
129 typedef enum _ClipRule {
130 	clipRuleEvenOdd = 0,
131 	clipRuleWinding = 1
132 } ClipRule;
133 
134 /* Line */
135 typedef enum _LineStyle {
136 	lineStyleSolid = 0,
137 	lineStyleDash = 1
138 } LineStyle;
139 
140 typedef enum _LineCap {
141 	lineCapButt = 0,
142 	lineCapRound = 1,
143 	lineCapSquare = 2
144 } LineCap;
145 
146 typedef enum _LineJoin {
147 	lineJoinMiter = 0,
148 	lineJoinRound = 1,
149 	lineJoinBevel = 2
150 } LineJoin;
151 
152 /* Brush */
153 typedef enum _BrushDataType {
154 	bdtypeNormal = 0
155 } BrushDataType;
156 
157 typedef struct BrushData_s {
158 	BrushDataType	type;
159 	int		width;
160 	int		height;
161 	int		pitch;
162 	void		*data;		// pointer to actual data
163 } BrushData;
164 
165 typedef struct Brush_s {
166 	ColorSpace	colorSpace;
167 	int		color[4];		/* aRGB quadruplet */
168 	int		xorg, yorg;		/* brush origin
169 						   ignored for SetBgColor */
170 	BrushData	*pbrush;		/* pointer to brush data
171 						   solid brush used, if null */
172 } Brush;
173 
174 
175 /* Misc. Flags */
176 #define	Arc			0	/* �߸� */
177 #define	Chord			1	/* �ݷ� */
178 #define	Pie			2	/* ��� */
179 #define	Clockwise			/* �������� */
180 #define	Counterclockwise		/* ȿ�������� */
181 #define	PathClose		0	/* Close path upon LinePath */
182 #define	PathOpen		1	/* Do not close path upon LinePath */
183 
184 /* CTM */
185 typedef struct CTM_s {
186 	float a, b, c, d, e, f;
187 } CTM;
188 
189 
190 extern int	errorno;
191 
192 /* KLUDGE!
193    The API draft specification requires that drivers only export the
194    OpenPrinter function so we have to declare all other functions as
195    static.  To avoid breaking the existing (broken) implementations,
196    you work around this by defining PDAPI_STRICT_SPEC.
197  */
198 #ifdef PDAPI_STRICT_SPEC
199 #define PDAPI_STATIC static
200 #else
201 #define PDAPI_STATIC
202 #endif
203 
204 /* The spec requires us to fill unsupported functionality slots in the
205    apiEntry[] passed into OpenPrinting() with NULL so we'd better make
206    sure it is defined.  */
207 #ifndef NULL
208 #define NULL 0
209 #endif
210 
211 /* �ץ�ȥ�������� */
212 /* Creating and Managing Print Contexts */
213 #ifdef PDAPI_STRICT_SPEC
214 int OpenPrinter(int outputFD, char *printerModel, int *nApiEntry, int (**apiEntry[])());
215 #else
216 int OpenPrinter(int outputFD, char *printerModel, int *nApiEntry, void *apiEntry[]);
217 #endif
218 PDAPI_STATIC int ClosePrinter(int printerContext);
219 
220 /* Job Control Operations */
221 PDAPI_STATIC int StartJob(int printerContext, char *jobInfo);
222 PDAPI_STATIC int EndJob(int printerContext);
223 PDAPI_STATIC int StartDoc(int printerContext, char *docInfo);
224 PDAPI_STATIC int EndDoc(int printerContext);
225 PDAPI_STATIC int StartPage(int printerContext, char *pageInfo);
226 PDAPI_STATIC int EndPage(int printerContext);
227 PDAPI_STATIC int QueryDeviceCapability(int printerContext, int queryflag, int buflen, char *infoBuf);
228 PDAPI_STATIC int QueryDeviceInfo(int printerContext, int queryflag, int buflen, char *infoBuf);
229 
230 /* Graphics State Object Operations */
231 PDAPI_STATIC int ResetCTM(int printerContext);
232 PDAPI_STATIC int SetCTM(int printerContext, CTM *pCTM);
233 PDAPI_STATIC int GetCTM(int printerContext, CTM *pCTM);
234 PDAPI_STATIC int InitGS(int printerContext);
235 PDAPI_STATIC int SaveGS(int printerContext);
236 PDAPI_STATIC int RestoreGS(int printerContext);
237 PDAPI_STATIC int QueryColorSpace(int printerContext, ColorSpace *pcspace, int *pnum);
238 PDAPI_STATIC int SetColorSpace(int printerContext, ColorSpace cspace);
239 PDAPI_STATIC int GetColorSpace(int printerContext, ColorSpace *pcspace);
240 PDAPI_STATIC int QueryROP(int printerContext, int *pnum, int *prop);
241 PDAPI_STATIC int SetROP(int printerContext, int rop);
242 PDAPI_STATIC int GetROP(int printerContext, int *prop);
243 PDAPI_STATIC int SetFillMode(int printerContext, FillMode fillmode);
244 PDAPI_STATIC int GetFillMode(int printerContext, FillMode* pfillmode);
245 PDAPI_STATIC int SetAlphaConstant(int printerContext, float alpha);
246 PDAPI_STATIC int GetAlphaConstant(int printerContext, float *palpha);
247 PDAPI_STATIC int SetLineWidth(int printerContext, Fix width);
248 PDAPI_STATIC int GetLineWidth(int printerContext, Fix *pwidth);
249 PDAPI_STATIC int SetLineDash(int printerContext, Fix pdash[], int num);
250 PDAPI_STATIC int GetLineDash(int printerContext, Fix pdash[], int *pnum);
251 PDAPI_STATIC int SetLineDashOffset(int printerContext, Fix offset);
252 PDAPI_STATIC int GetLineDashOffset(int printerContext, Fix *poffset);
253 PDAPI_STATIC int SetLineStyle(int printerContext, LineStyle linestyle);
254 PDAPI_STATIC int GetLineStyle(int printerContext, LineStyle *plinestyle);
255 PDAPI_STATIC int SetLineCap(int printerContext, LineCap linecap);
256 PDAPI_STATIC int GetLineCap(int printerContext, LineCap *plinecap);
257 PDAPI_STATIC int SetLineJoin(int printerContext, LineJoin linejoin);
258 PDAPI_STATIC int GetLineJoin(int printerContext, LineJoin *plinejoin);
259 PDAPI_STATIC int SetMiterLimit(int printerContext, Fix miterlimit);
260 PDAPI_STATIC int GetMiterLimit(int printerContext, Fix *pmiterlimit);
261 PDAPI_STATIC int SetPaintMode(int printerContext, PaintMode paintmode);
262 PDAPI_STATIC int GetPaintMode(int printerContext, PaintMode *ppaintmode);
263 PDAPI_STATIC int SetStrokeColor(int printerContext, Brush *brush);
264 PDAPI_STATIC int SetFillColor(int printerContext, Brush *brush);
265 PDAPI_STATIC int SetBgColor(int printerContext, Brush *brush);
266 
267 /* Path Operations */
268 PDAPI_STATIC int NewPath(int printerContext);
269 PDAPI_STATIC int EndPath(int printerContext);
270 PDAPI_STATIC int StrokePath(int printerContext);
271 PDAPI_STATIC int FillPath(int printerContext);
272 PDAPI_STATIC int StrokeFillPath(int printerContext);
273 PDAPI_STATIC int SetClipPath(int printerContext, ClipRule clipRule);
274 PDAPI_STATIC int ResetClipPath( int printerContext);
275 PDAPI_STATIC int SetCurrentPoint(int printerContext, Fix x, Fix y);
276 PDAPI_STATIC int LinePath(int printerContext, int flag, int npoints, Point *points);
277 PDAPI_STATIC int PolygonPath(int printerContext, int npolygons, int *nvertexes, Point *points);
278 PDAPI_STATIC int RectanglePath(int printerContext, int nrectangles, Rectangle *rectangles);
279 PDAPI_STATIC int RoundRectanglePath(int printerContext, int nrectangles, RoundRectangle *rectangles);
280 PDAPI_STATIC int BezierPath(int printerContext, int npoints, Point *points);
281 PDAPI_STATIC int ArcPath(int printerContext, int kind, int dir, Fix bbx0, Fix bby0, Fix bbx1, Fix bby1, Fix x0, Fix y0, Fix x1, Fix y1);
282 
283 /* Text Operations */
284 PDAPI_STATIC int DrawBitmapText(int printerContext, int width, int height, int pitch, void *fontdata);
285 
286 /* Bitmap Image Operations */
287 PDAPI_STATIC int DrawImage(int printerContext, int sourceWidth, int sourceHeight, int colorSpace, ImageFormat imageFormat, Rectangle destinationSize, int count, void *imageData);
288 PDAPI_STATIC int StartDrawImage(int printerContext, int sourceWidth, int sourceHeight, int colorSpace, ImageFormat imageFormat, Rectangle destinationSize);
289 PDAPI_STATIC int TransferDrawImage(int printerContext, int count, void *imageData);
290 PDAPI_STATIC int EndDrawImage(int printerContext);
291 
292 /* Scan Line Operations */
293 PDAPI_STATIC int StartScanline(int printerContext, int yposition);
294 PDAPI_STATIC int Scanline(int printerContext, int nscanpairs, int *scanpairs);
295 PDAPI_STATIC int EndScanline(int printerContext);
296 
297 /* Raster Image Operations */
298 PDAPI_STATIC int StartRaster(int printerContext, int rasterWidth);
299 PDAPI_STATIC int TransferRasterData(int printerContext, int count, unsigned char *data);
300 PDAPI_STATIC int SkipRaster(int printerContext, int count);
301 PDAPI_STATIC int EndRaster(int printerContext);
302 
303 /* Stream Data Operations */
304 PDAPI_STATIC int StartStream(int printerContext);
305 PDAPI_STATIC int TransferStreamData(int printerContext, int count, void *data);
306 PDAPI_STATIC int EndStream(int printerContext);
307 
308 
309 
310 #endif /* _PDAPI_H */
311