xref: /plan9/sys/src/cmd/gs/src/gdevmacpictop.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1997-2002 artofcode LLC.  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: gdevmacpictop.h,v 1.6 2003/01/06 23:37:58 giles Exp $ */
18 
19 /* Helpers for working with Classic MacOS Quickdraw pictures */
20 /* (obsoleted by the DISPLAY device) */
21 
22 #ifndef gdevmacpictop_INCLUDED
23 #  define gdevmacpictop_INCLUDED
24 
25 #include <QDOffscreen.h>
26 
27 
28 /************************/
29 /* PICT data structures */
30 /************************/
31 
32 /* write raw data to PICT file */
33 #define PICTWriteByte(ptr, data)	*((unsigned char*)  (ptr))++ = data;
34 #define PICTWriteInt(ptr, data)		*((short*) (ptr))++ = data;
35 #define PICTWriteLong(ptr, data)	*((long*)  (ptr))++ = data;
36 
37 #define PICTWriteFillByte(ptr)		PICTWriteByte(ptr, 0);
38 
39 /* write a PICT opcode */
40 #define PICTWriteOpcode(ptr, op)	PICTWriteInt(ptr, op);
41 
42 
43 /*****************************/
44 /* QuickDraw data structures */
45 /*****************************/
46 
47 /* write a Point structure */
48 #define PICTWritePoint(ptr, h, v)															\
49 		{																					\
50 			PICTWriteInt(ptr, v);	/* vertical coordinate */								\
51 			PICTWriteInt(ptr, h);	/* horizontal coordinate */								\
52 		}
53 
54 /* write a Rect structure */
55 #define PICTWriteRect(ptr, x, y, w, h)														\
56 		{																					\
57 			PICTWritePoint(ptr, x, y);		/* upper-left corner  */						\
58 			PICTWritePoint(ptr, x+w, y+h);	/* lower-right corner */						\
59 		}
60 
61 /* write a rectangular Region structure */
62 #define PICTWriteRegionRectangular(ptr, x, y, w, h)											\
63 		{																					\
64 			PICTWriteInt(ptr, 10);			/* rgnSize */									\
65 			PICTWriteRect(ptr, x, y, w, h);	/* rgnBBox */									\
66 		}
67 
68 /* write a non-rectangular Region structure */
69 #define PICTWriteRegion(ptr, x, y, b, h, size, dataptr)										\
70 		{																					\
71 			PICTWriteInt(ptr, 10+size);		/* rgnSize */									\
72 			PICTWriteRect(ptr, x, y, w, h);	/* rgnBBox */									\
73 			memcpy(ptr, dataptr, size);		/* additional data */							\
74 			((char*)(ptr)) += size;															\
75 		}
76 
77 /* write a pattern */
78 #define PICTWritePattern(ptr, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8)		\
79 		{																					\
80 			PICTWriteByte(ptr, byte1);		/* pattern */									\
81 			PICTWriteByte(ptr, byte2);		/* pattern */									\
82 			PICTWriteByte(ptr, byte3);		/* pattern */									\
83 			PICTWriteByte(ptr, byte4);		/* pattern */									\
84 			PICTWriteByte(ptr, byte5);		/* pattern */									\
85 			PICTWriteByte(ptr, byte6);		/* pattern */									\
86 			PICTWriteByte(ptr, byte7);		/* pattern */									\
87 			PICTWriteByte(ptr, byte8);		/* pattern */									\
88 		}
89 
90 /* write a RGBColor structure */
91 #define PICTWriteRGBColor(ptr, r, g, b)														\
92 		{																					\
93 			PICTWriteInt(ptr, r);			/* red   */										\
94 			PICTWriteInt(ptr, g);			/* green */										\
95 			PICTWriteInt(ptr, b);			/* blue  */										\
96 		}
97 
98 /* write a ColorSpec structure */
99 #define PICTWriteColorSpec(ptr, value, r, g, b)														\
100 		{																					\
101 			PICTWriteInt(ptr, value);			/* value */									\
102 			PICTWriteRGBColor(ptr, r, g, b);	/* color */									\
103 		}
104 
105 /* write a ColorTable structure */
106 #define PICTWriteColorTable(ptr, seed, numEntries, cspecarr)								\
107 		{																					\
108 			int i;																			\
109 			PICTWriteLong(ptr, seed);			/* ctSeed  */								\
110 			PICTWriteInt(ptr, 0);				/* ctFlags */								\
111 			PICTWriteInt(ptr, numEntries-1);	/* ctSize  */								\
112 			for (i=0; i<numEntries; i++)		/* ctTable */								\
113 				PICTWriteColorSpec(ptr, cspecarr[i].value,									\
114 										cspecarr[i].rgb.red,								\
115 										cspecarr[i].rgb.green,								\
116 										cspecarr[i].rgb.blue);								\
117 		}
118 
119 /* write a PixMap structure */
120 #define PICTWritePixMap(ptr, x, y, w, h, rowBytes,											\
121 						packType, packSize,													\
122 						hRes, vRes, pixelSize)												\
123 		{																					\
124 			PICTWriteInt(ptr, 0x8000+rowBytes);		/* rowBytes   */						\
125 			PICTWriteRect(ptr, x, y, w, h);			/* bounds     */						\
126 			PICTWriteInt(ptr, 0);					/* pmVersion  */						\
127 			PICTWriteInt(ptr, packType);			/* packType   */						\
128 			PICTWriteLong(ptr, (packType ? packSize : 0));		/* packSize   */			\
129 			PICTWriteLong(ptr, hRes);				/* hRes       */						\
130 			PICTWriteLong(ptr, vRes);				/* vRes       */						\
131 			if (pixelSize < 16)	{				/* indexed */								\
132 				PICTWriteInt(ptr, 0);				/* pixelType  */						\
133 				PICTWriteInt(ptr, pixelSize);		/* pixelSize  */						\
134 				PICTWriteInt(ptr, 1);				/* cmpCount   */						\
135 				PICTWriteInt(ptr, pixelSize);		/* cmpSize    */						\
136 			} else {							/* direct  */								\
137 				PICTWriteInt(ptr, RGBDirect);		/* pixelType  */						\
138 				PICTWriteInt(ptr, pixelSize);		/* pixelSize  */						\
139 				PICTWriteInt(ptr, 3);				/* cmpCount   */						\
140 				PICTWriteInt(ptr, (pixelSize==16 ? 5 : 8));		/* cmpSize    */			\
141 			}																				\
142 			PICTWriteLong(ptr, 0);					/* planeBytes */						\
143 			PICTWriteLong(ptr, 0);					/* pmTable    */						\
144 			PICTWriteLong(ptr, 0);					/* pmReserved */						\
145 		}
146 
147 /* write PackBits data */
148 #define PICTWriteDataPackBits(ptr, base, rowBytes, lines)									\
149 		{																					\
150 			short	byteCount;																\
151 			if (raster < 8) {		/* data uncompressed */									\
152 				byteCount = rowBytes * lines;												\
153 				memcpy(ptr, base, byteCount);		/* bitmap data */						\
154 				(char*)(ptr) += byteCount;													\
155 			} else {				/* raster >= 8 use PackBits compression */				\
156 				Ptr		destBufBegin = (Ptr) malloc(raster + (raster+126)/127), destBuf,	\
157 						srcBuf = (Ptr) base;												\
158 				short	i, len;																\
159 																							\
160 				byteCount = 0;																\
161 				for (i=0; i<lines; i++) {													\
162 					destBuf = destBufBegin;													\
163 					PackBits(&srcBuf, &destBuf, rowBytes);									\
164 					len = destBuf - destBufBegin;											\
165 					if (rowBytes > 250) {													\
166 						PICTWriteInt(ptr, len);												\
167 						byteCount += 2;														\
168 					} else {																\
169 						PICTWriteByte(ptr, len);											\
170 						byteCount++;														\
171 					}																		\
172 																							\
173 					memcpy(ptr, destBufBegin, len);											\
174 					(char*)(ptr) += len;													\
175 					byteCount += len;														\
176 				}																			\
177 				free(destBufBegin);															\
178 			}																				\
179 																							\
180 			if (byteCount % 2)																\
181 				PICTWriteFillByte(ptr);														\
182 		}
183 
184 /* write text */
185 #define PICTWriteText(ptr, textptr /* pascal string*/)										\
186 		{																					\
187 			memcpy(ptr, textptr, textptr[0]+1);				/* copy string */				\
188 			(char*)(ptr) += textptr[0]+1;													\
189 		}
190 
191 
192 
193 /****************/
194 /* PICT Opcodes */
195 /****************/
196 
197 
198 #define PICT_NOP(ptr)																		\
199 		{																					\
200 			PICTWriteOpcode(ptr, 0x0000);						/* NOP opcode */			\
201 		}
202 
203 #define PICT_Clip_Rectangular(ptr, x, y, w, h)												\
204 		{																					\
205 			PICTWriteOpcode(ptr, 0x0001);						/* Clip opcode */			\
206 			PICTWriteRegionRectangular(ptr, x, y, w, h);		/* clipRgn */				\
207 		}
208 
209 #define PICT_Clip(ptr, x, y, w, h, size, dataptr)											\
210 		{																					\
211 			PICTWriteOpcode(ptr, 0x0001);						/* Clip opcode */			\
212 			PICTWriteRegion(ptr, x, y, w, h, size, dataptr);	/* clipRgn */				\
213 		}
214 
215 #define PICT_BkPat(ptr, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8)				\
216 		{																					\
217 			PICTWriteOpcode(ptr, 0x0002);						/* BkPat opcode */			\
218 			PICTWritePattern(ptr, byte1, byte2, byte3, byte4,	/* Pattern data */			\
219 								  byte5, byte6, byte7, byte8);								\
220 		}
221 
222 #define PICT_TxFont(ptr, font)																\
223 		{																					\
224 			PICTWriteOpcode(ptr, 0x0003);						/* TxFont opcode */			\
225 			PICTWriteInt(ptr, font);							/* Font number   */			\
226 		}
227 
228 #define PICT_TxFace(ptr, style)																\
229 		{																					\
230 			PICTWriteOpcode(ptr, 0x0004);						/* TxFace opcode */			\
231 			PICTWriteByte(ptr, style);							/* Font style    */			\
232 			PICTWriteFillByte(ptr);								/* Fill byte     */			\
233 		}
234 
235 #define PICT_TxMode(ptr, mode)																\
236 		{																					\
237 			PICTWriteOpcode(ptr, 0x0005);						/* TxMode opcode */			\
238 			PICTWriteInt(ptr, mode);							/* Source mode   */			\
239 		}
240 
241 #define PICT_PnSize(ptr, w, h)																\
242 		{																					\
243 			PICTWriteOpcode(ptr, 0x0006);						/* PnSize opcode */			\
244 			PICTWritePoint(w, h);								/* Pen size      */			\
245 		}
246 
247 #define PICT_PnMode(ptr, mode)																\
248 		{																					\
249 			PICTWriteOpcode(ptr, 0x0007);						/* PnMode opcode */			\
250 			PICTWriteInt(ptr, mode);							/* Pen mode      */			\
251 		}
252 
253 #define PICT_PnPat(ptr, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8)				\
254 		{																					\
255 			PICTWriteOpcode(ptr, 0x0009);						/* PnPat opcode */			\
256 			PICTWritePattern(ptr, byte1, byte2, byte3, byte4,	/* Pattern data */			\
257 								  byte5, byte6, byte7, byte8);								\
258 		}
259 
260 #define PICT_FillPat(ptr, byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8)			\
261 		{																					\
262 			PICTWriteOpcode(ptr, 0x000A);						/* FillPat opcode */		\
263 			PICTWritePattern(ptr, byte1, byte2, byte3, byte4,	/* Pattern data   */		\
264 								  byte5, byte6, byte7, byte8);								\
265 		}
266 
267 #define PICT_OvSize(ptr, w, h)																\
268 		{																					\
269 			PICTWriteOpcode(ptr, 0x000B);						/* OvSize opcode */			\
270 			PICTWritePoint(w, h);								/* Oval size     */			\
271 		}
272 
273 #define PICT_Origin(ptr, dh, dv)															\
274 		{																					\
275 			PICTWriteOpcode(ptr, 0x000C);						/* Origin opcode */			\
276 			PICTWriteInt(ptr, dh);								/* dh            */			\
277 			PICTWriteInt(ptr, dv);								/* dv            */			\
278 		}
279 
280 #define PICT_TxSize(ptr, size)																\
281 		{																					\
282 			PICTWriteOpcode(ptr, 0x000D);						/* TxSize opcode */			\
283 			PICTWriteInt(ptr, size);							/* Text Size     */			\
284 		}
285 
286 #define PICT_FgColor(ptr, color)															\
287 		{																					\
288 			PICTWriteOpcode(ptr, 0x000E);						/* FgColor opcode   */		\
289 			PICTWriteLong(ptr, color);							/* Foreground color */		\
290 		}
291 
292 #define PICT_BkColor(ptr, color)															\
293 		{																					\
294 			PICTWriteOpcode(ptr, 0x000F);						/* BkColor opcode   */		\
295 			PICTWriteLong(ptr, color);							/* Background color */		\
296 		}
297 
298 #define PICT_TxRatio(ptr, num, denom)														\
299 		{																					\
300 			PICTWriteOpcode(ptr, 0x0010);						/* TxRatio opcode      */	\
301 			PICTWritePoint(ptr, num);							/* Numerator (Point)   */	\
302 			PICTWritePoint(ptr, denom);							/* Denominator (Point) */	\
303 		}
304 
305 #define PICT_VersionOp(ptr, version)														\
306 		{																					\
307 			PICTWriteOpcode(ptr, 0x0011);						/* VersionOp opcode */		\
308 			PICTWriteByte(ptr, version);						/* Version          */		\
309 			PICTWriteFillByte(ptr);								/* Fill byte        */		\
310 		}
311 
312 #define PICT_RGBFgCol(ptr, r, g, b)															\
313 		{																					\
314 			PICTWriteOpcode(ptr, 0x001A);						/* RGBFgCol opcode  */		\
315 			PICTWriteRGBColor(ptr, r, g, b);					/* Foreground color */		\
316 		}
317 
318 #define PICT_RGBBkCol(ptr, r, g, b)															\
319 		{																					\
320 			PICTWriteOpcode(ptr, 0x001B);						/* RGBBkCol opcode  */		\
321 			PICTWriteRGBColor(ptr, r, g, b);					/* Background color */		\
322 		}
323 
324 #define PICT_HiliteMode(ptr)																\
325 		{																					\
326 			PICTWriteOpcode(ptr, 0x001C);						/* HiliteMode opcode */		\
327 		}
328 
329 #define PICT_HiliteColor(ptr, r, g, b)														\
330 		{																					\
331 			PICTWriteOpcode(ptr, 0x001D);						/* HiliteColor opcode */	\
332 			PICTWriteRGBColor(ptr, r, g, b);					/* Highlight color    */	\
333 		}
334 
335 #define PICT_DefHilite(ptr)																	\
336 		{																					\
337 			PICTWriteOpcode(ptr, 0x001E);						/* DefHilite opcode */		\
338 		}
339 
340 #define PICT_OpColor(ptr, r, g, b)															\
341 		{																					\
342 			PICTWriteOpcode(ptr, 0x001F);						/* OpColor opcode */		\
343 			PICTWriteRGBColor(ptr, r, g, b);					/* Opcolor        */		\
344 		}
345 
346 #define PICT_Line(ptr, x0, y0, x1, y1)														\
347 		{																					\
348 			PICTWriteOpcode(ptr, 0x0020);						/* Line opcode */			\
349 			PICTWritePoint(ptr, x0, y0);						/* pnLoc       */			\
350 			PICTWritePoint(ptr, x1, y1);						/* newPt       */			\
351 		}
352 
353 #define PICT_LineFrom(ptr, x, y)															\
354 		{																					\
355 			PICTWriteOpcode(ptr, 0x0021);						/* LineFrom opcode */		\
356 			PICTWritePoint(ptr, x, y);							/* newPt           */		\
357 		}
358 
359 #define PICT_ShortLine(ptr, x, y, dh, dv)													\
360 		{																					\
361 			PICTWriteOpcode(ptr, 0x0022);						/* ShortLine opcode */		\
362 			PICTWritePoint(ptr, x, y);							/* pnLoc            */		\
363 			PICTWriteByte(ptr, dh);								/* dh               */		\
364 			PICTWriteByte(ptr, dv);								/* dv               */		\
365 		}
366 
367 #define PICT_ShortLineFrom(ptr, dh, dv)														\
368 		{																					\
369 			PICTWriteOpcode(ptr, 0x0023);						/* ShortLineFrom opcode */	\
370 			PICTWriteByte(ptr, dh);								/* dh                   */	\
371 			PICTWriteByte(ptr, dv);								/* dv                   */	\
372 		}
373 
374 #define PICT_LongText(ptr, x, y, textptr /* pascal string */)								\
375 		{																					\
376 			PICTWriteOpcode(ptr, 0x0028);						/* LongText opcode */		\
377 			PICTWritePoint(ptr, x, y);							/* Point           */		\
378 			PICTWriteText(ptr, textptr);						/* text            */		\
379 			if ((textptr[0]+1) % 2) PICTWriteFillByte(ptr);									\
380 		}
381 
382 #define PICT_DHText(ptr, dh, textptr /* pascal string */)									\
383 		{																					\
384 			PICTWriteOpcode(ptr, 0x0029);						/* DHText opcode */			\
385 			PICTWriteByte(ptr, dh);								/* dh            */			\
386 			PICTWriteText(ptr, textptr);						/* text            */		\
387 			if (textptr[0] % 2) PICTWriteFillByte(ptr);										\
388 		}
389 
390 #define PICT_DVText(ptr, dv, textptr /* pascal string */)									\
391 		{																					\
392 			PICTWriteOpcode(ptr, 0x002A);						/* DVText opcode */			\
393 			PICTWriteByte(ptr, dv);								/* dv            */			\
394 			PICTWriteText(ptr, textptr);						/* text            */		\
395 			if (textptr[0] % 2) PICTWriteFillByte(ptr);										\
396 		}
397 
398 #define PICT_DHDVText(ptr, dh, dv, textptr /* pascal string */)								\
399 		{																					\
400 			PICTWriteOpcode(ptr, 0x002B);						/* DHDVText opcode */		\
401 			PICTWriteByte(ptr, dh);								/* dh              */		\
402 			PICTWriteByte(ptr, dv);								/* dv              */		\
403 			PICTWriteText(ptr, textptr);						/* text            */		\
404 			if ((textptr[0]+1) % 2) PICTWriteFillByte(ptr);									\
405 		}
406 
407 #define PICT_fontName(ptr, id, nameptr /* pascal string */)									\
408 		{																					\
409 			PICTWriteOpcode(ptr, 0x002C);						/* fontName opcode */		\
410 			PICTWriteInt(ptr, nameptr[0]+1+2);					/* data length     */		\
411 			PICTWriteInt(ptr, id);								/* font id         */		\
412 			PICTWriteText(ptr, nameptr);						/* text            */		\
413 			if ((nameptr[0]+1) % 2) PICTWriteFillByte(ptr);									\
414 		}
415 
416 #define PICT_frameRect(ptr, x, y, w, h)														\
417 		{																					\
418 			PICTWriteOpcode(ptr, 0x0030);						/* frameRect opcode */		\
419 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle        */		\
420 		}
421 
422 #define PICT_paintRect(ptr, x, y, w, h)														\
423 		{																					\
424 			PICTWriteOpcode(ptr, 0x0031);						/* paintRect opcode */		\
425 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle        */		\
426 		}
427 
428 #define PICT_eraseRect(ptr, x, y, w, h)														\
429 		{																					\
430 			PICTWriteOpcode(ptr, 0x0032);						/* eraseRect opcode */		\
431 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle        */		\
432 		}
433 
434 #define PICT_invertRect(ptr, x, y, w, h)													\
435 		{																					\
436 			PICTWriteOpcode(ptr, 0x0033);						/* invertRect opcode */		\
437 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle         */		\
438 		}
439 
440 #define PICT_fillRect(ptr, x, y, w, h)														\
441 		{																					\
442 			PICTWriteOpcode(ptr, 0x0034);						/* fillRect opcode */		\
443 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle       */		\
444 		}
445 
446 #define PICT_frameSameRect(ptr)																\
447 		{																					\
448 			PICTWriteOpcode(ptr, 0x0038);						/* frameSameRect opcode */	\
449 		}
450 
451 #define PICT_paintSameRect(ptr)																\
452 		{																					\
453 			PICTWriteOpcode(ptr, 0x0039);						/* paintSameRect opcode */	\
454 		}
455 
456 #define PICT_eraseSameRect(ptr)																\
457 		{																					\
458 			PICTWriteOpcode(ptr, 0x003A);						/* eraseSameRect opcode */	\
459 		}
460 
461 #define PICT_invertSameRect(ptr)															\
462 		{																					\
463 			PICTWriteOpcode(ptr, 0x003B);						/* invertSameRect opcode */	\
464 		}
465 
466 #define PICT_fillSameRect(ptr)																\
467 		{																					\
468 			PICTWriteOpcode(ptr, 0x003C);						/* fillSameRect opcode */	\
469 		}
470 
471 #define PICT_frameRRect(ptr, x, y, w, h)													\
472 		{																					\
473 			PICTWriteOpcode(ptr, 0x0040);						/* frameRRect opcode */		\
474 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle         */		\
475 		}
476 
477 #define PICT_paintRRect(ptr, x, y, w, h)													\
478 		{																					\
479 			PICTWriteOpcode(ptr, 0x0041);						/* paintRRect opcode */		\
480 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle         */		\
481 		}
482 
483 #define PICT_eraseRRect(ptr, x, y, w, h)													\
484 		{																					\
485 			PICTWriteOpcode(ptr, 0x0042);						/* eraseRRect opcode */		\
486 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle         */		\
487 		}
488 
489 #define PICT_invertRRect(ptr, x, y, w, h)													\
490 		{																					\
491 			PICTWriteOpcode(ptr, 0x0043);						/* invertRRect opcode */	\
492 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle          */	\
493 		}
494 
495 #define PICT_fillRRect(ptr, x, y, w, h)														\
496 		{																					\
497 			PICTWriteOpcode(ptr, 0x0044);						/* fillRRect opcode */		\
498 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle        */		\
499 		}
500 
501 #define PICT_frameSameRRect(ptr)															\
502 		{																					\
503 			PICTWriteOpcode(ptr, 0x0048);						/* frameSameRRect opcode */	\
504 		}
505 
506 #define PICT_paintSameRRect(ptr)															\
507 		{																					\
508 			PICTWriteOpcode(ptr, 0x0049);						/* paintSameRRect opcode */	\
509 		}
510 
511 #define PICT_eraseSameRRect(ptr)															\
512 		{																					\
513 			PICTWriteOpcode(ptr, 0x004A);						/* eraseSameRRect opcode */	\
514 		}
515 
516 #define PICT_invertSameRRect(ptr)															\
517 		{																					\
518 			PICTWriteOpcode(ptr, 0x004B);						/* invertSameRRect opcode */\
519 		}
520 
521 #define PICT_fillSameRRect(ptr)																\
522 		{																					\
523 			PICTWriteOpcode(ptr, 0x004C);						/* fillSameRRect opcode */	\
524 		}
525 
526 #define PICT_frameOval(ptr, x, y, w, h)														\
527 		{																					\
528 			PICTWriteOpcode(ptr, 0x0050);						/* frameOval opcode */		\
529 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle        */		\
530 		}
531 
532 #define PICT_paintOval(ptr, x, y, w, h)														\
533 		{																					\
534 			PICTWriteOpcode(ptr, 0x0051);						/* paintOval opcode */		\
535 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle        */		\
536 		}
537 
538 #define PICT_eraseOval(ptr, x, y, w, h)														\
539 		{																					\
540 			PICTWriteOpcode(ptr, 0x0052);						/* eraseOval opcode */		\
541 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle        */		\
542 		}
543 
544 #define PICT_invertOval(ptr, x, y, w, h)													\
545 		{																					\
546 			PICTWriteOpcode(ptr, 0x0053);						/* invertOval opcode */		\
547 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle         */		\
548 		}
549 
550 #define PICT_fillOval(ptr, x, y, w, h)														\
551 		{																					\
552 			PICTWriteOpcode(ptr, 0x0054);						/* fillOval opcode */		\
553 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle       */		\
554 		}
555 
556 #define PICT_frameSameOval(ptr)																\
557 		{																					\
558 			PICTWriteOpcode(ptr, 0x0058);						/* frameSameOval opcode */	\
559 		}
560 
561 #define PICT_paintSameOval(ptr)																\
562 		{																					\
563 			PICTWriteOpcode(ptr, 0x0059);						/* paintSameOval opcode */	\
564 		}
565 
566 #define PICT_eraseSameOval(ptr)																\
567 		{																					\
568 			PICTWriteOpcode(ptr, 0x005A);						/* eraseSameOval opcode */	\
569 		}
570 
571 #define PICT_invertSameOval(ptr)															\
572 		{																					\
573 			PICTWriteOpcode(ptr, 0x005B);						/* invertSameOval opcode */	\
574 		}
575 
576 #define PICT_fillSameOval(ptr)																\
577 		{																					\
578 			PICTWriteOpcode(ptr, 0x005C);						/* fillSameOval opcode */	\
579 		}
580 
581 #define PICT_frameArc(ptr, x, y, w, h, startAngle, arcAngle)								\
582 		{																					\
583 			PICTWriteOpcode(ptr, 0x0060);						/* frameArc opcode */		\
584 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle       */		\
585 			PICTWriteInt(ptr, startAngle);						/* startAngle      */		\
586 			PICTWriteInt(ptr, arcAngle);						/* arcAngle        */		\
587 		}
588 
589 #define PICT_paintArc(ptr, x, y, w, h, startAngle, arcAngle)								\
590 		{																					\
591 			PICTWriteOpcode(ptr, 0x0061);						/* paintArc opcode */		\
592 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle       */		\
593 			PICTWriteInt(ptr, startAngle);						/* startAngle      */		\
594 			PICTWriteInt(ptr, arcAngle);						/* arcAngle        */		\
595 		}
596 
597 #define PICT_eraseArc(ptr, x, y, w, h, startAngle, arcAngle)								\
598 		{																					\
599 			PICTWriteOpcode(ptr, 0x0062);						/* eraseArc opcode */		\
600 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle       */		\
601 			PICTWriteInt(ptr, startAngle);						/* startAngle      */		\
602 			PICTWriteInt(ptr, arcAngle);						/* arcAngle        */		\
603 		}
604 
605 #define PICT_invertArc(ptr, x, y, w, h, startAngle, arcAngle)								\
606 		{																					\
607 			PICTWriteOpcode(ptr, 0x0063);						/* invertArc opcode */		\
608 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle        */		\
609 			PICTWriteInt(ptr, startAngle);						/* startAngle       */		\
610 			PICTWriteInt(ptr, arcAngle);						/* arcAngle         */		\
611 		}
612 
613 #define PICT_fillArc(ptr, x, y, w, h, startAngle, arcAngle)									\
614 		{																					\
615 			PICTWriteOpcode(ptr, 0x0064);						/* fillArc opcode */		\
616 			PICTWriteRect(ptr, x, y, w, h);						/* Rectangle      */		\
617 			PICTWriteInt(ptr, startAngle);						/* startAngle     */		\
618 			PICTWriteInt(ptr, arcAngle);						/* arcAngle       */		\
619 		}
620 
621 /* use only with rowBytes < 8 !! */
622 #define PICT_BitsRect_BitMap(ptr, x0, y0, w0, h0, x1, y1, w1, h1, rowBytes, mode, dataPtr)	\
623 		{																					\
624 			PICTWriteOpcode(ptr, 0x0090);						/* BitsRect opcode */		\
625 			PICTWriteInt(ptr, rowBytes);						/* rowBytes        */		\
626 			PICTWriteRect(ptr, x1, y1, w1, h1);					/* bounds x1????   */		\
627 			PICTWriteRect(ptr, x0, y0, w0, h0);					/* srcRect         */		\
628 			PICTWriteRect(ptr, x1, y1, w1, h1);					/* dstRect         */		\
629 			PICTWriteInt(ptr, mode);							/* mode            */		\
630 			memcpy(ptr, dataPtr, h0*rowBytes);					/* BitMap data     */		\
631 		}
632 
633 #define PICT_PackBitsRect_BitMap(ptr, x0, y0, w0, h0, x1, y1, w1, h1, rowBytes, mode,		\
634 								 dataPtr, size)												\
635 		{																					\
636 			PICTWriteOpcode(ptr, 0x0098);						/* PackBitsRect opcode */	\
637 			PICTWriteInt(ptr, rowBytes);						/* rowBytes        */		\
638 			PICTWriteRect(ptr, x1, y1, w1, h1);					/* bounds x1????   */		\
639 			PICTWriteRect(ptr, x0, y0, w0, h0);					/* srcRect         */		\
640 			PICTWriteRect(ptr, x1, y1, w1, h1);					/* dstRect         */		\
641 			PICTWriteInt(ptr, mode);							/* mode            */		\
642 			memcpy(ptr, dataPtr, size);							/* BitMap data     */		\
643 		}
644 
645 #define PICT_OpEndPic(ptr)																	\
646 		{																					\
647 			PICTWriteOpcode(ptr, 0x00FF);						/* OpEndPic opcode */		\
648 		}
649 
650 /* same as PICT_OpEndPic, but doesn't move pointer */
651 #define PICT_OpEndPicGoOn(ptr)																\
652 		{																					\
653 			*(ptr) = 0x00FF;									/* OpEndPic opcode */		\
654 		}
655 
656 
657 
658 
659 
660 
661 
662 
663 /******************************/
664 /* ghostscript to PICT macros */
665 /******************************/
666 
667 /* set forground color to black and background color to white */
668 #define GSSetStdCol(ptr)																	\
669 		{																					\
670 			PICT_RGBFgCol(ptr, 0x0000, 0x0000, 0x0000);		/* black */						\
671 			PICT_RGBBkCol(ptr, 0xFFFF, 0xFFFF, 0xFFFF);		/* white */						\
672 		}
673 
674 #define GSSetFgCol(dev, ptr, col)															\
675 		{																					\
676 			gx_color_value	rgb[3];																	\
677 			(*dev_proc(dev, map_color_rgb))(dev, col, rgb);									\
678 			PICT_RGBFgCol(ptr, rgb[0], rgb[1], rgb[2]);										\
679 		}
680 
681 #define GSSetBkCol(dev, ptr, col)															\
682 		{																					\
683 			gx_color_value	rgb[3];																	\
684 			(*dev_proc(dev, map_color_rgb))(dev, col, rgb);									\
685 			PICT_RGBBkCol(ptr, rgb[0], rgb[1], rgb[2]);										\
686 		}
687 
688 #endif /* gdevmacpictop_INCLUDED */
689