gdevmacpictop.h 24 KB

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