~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/gdevmacpictop.h

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

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