You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HwmfTernaryRasterOp.java 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.hwmf.record;
  16. /**
  17. * Each ternary raster operation code represents a Boolean operation in which the values of the pixels in
  18. * the source, the selected brush, and the destination are combined. Following are the three operands
  19. * used in these operations.
  20. *
  21. * <table>
  22. * <tr><th>Operand</th><th>Meaning</th></tr>
  23. * <tr><td>D</td><td>Destination bitmap</td></tr>
  24. * <tr><td>P</td><td>Selected brush (also called pattern)</td></tr>
  25. * <tr><td>S</td><td>Source bitmap</td></tr>
  26. * </table>
  27. *
  28. * Following are the Boolean operators used in these operations.
  29. * <table>
  30. * <tr><th>Operand</th><th>Meaning</th></tr>
  31. * <tr><td>a</td><td>Bitwise AND</td></tr>
  32. * <tr><td>n</td><td>Bitwise NOT (inverse)</td></tr>
  33. * <tr><td>o</td><td>Bitwise OR</td></tr>
  34. * <tr><td>x</td><td>Bitwise exclusive OR (XOR)</td></tr>
  35. * </table>
  36. *
  37. * All Boolean operations are presented in reverse Polish notation. For example, the following operation
  38. * replaces the values of the pixels in the destination bitmap with a combination of the pixel values of the
  39. * source and brush: PSo.
  40. *
  41. * The following operation combines the values of the pixels in the source and brush with the pixel values
  42. * of the destination bitmap: DPSoo (there are alternative spellings of some functions, so although a
  43. * particular spelling MAY NOT be listed in the enumeration, an equivalent form SHOULD be).
  44. *
  45. * Each raster operation code is a 32-bit integer whose high-order word is a Boolean operation index and
  46. * whose low-order word is the operation code. The 16-bit operation index is a zero-extended, 8-bit
  47. * value that represents the result of the Boolean operation on predefined brush, source, and destination
  48. * values. For example, the operation indexes for the PSo and DPSoo operations are shown in the
  49. * following list.
  50. *
  51. * <table>
  52. * <tr><th>P</th><th>S</th><th>D</th><th>DPo</th><th>DPan</th></tr>
  53. * <tr><td>0</td><td>0</td><td>0</td><td>0</td><td>0</td></tr>
  54. * <tr><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
  55. * <tr><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
  56. * <tr><td>0</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>
  57. * <tr><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td></tr>
  58. * <tr><td>1</td><td>0</td><td>1</td><td>1</td><td>1</td></tr>
  59. * <tr><td>1</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
  60. * <tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr>
  61. * </table>
  62. *
  63. * The operation indexes are determined by reading the binary values in a column of the table from the
  64. * bottom up. For example, in the PSo column, the binary value is 11111100, which is equivalent to 00FC
  65. * (hexadecimal is implicit for these values), which is the operation index for PSo.
  66. *
  67. * Using this method, DPSoo can be seen to have the operation index 00FE. Operation indexes define the
  68. * locations of corresponding raster operation codes in the preceding enumeration. The PSo operation is
  69. * in line 252 (0x00FC) of the enumeration; DPSoo is in line 254 (0x00FE).
  70. *
  71. * The most commonly used raster operations have been given explicit enumeration names, which
  72. * SHOULD be used; examples are PATCOPY and WHITENESS.
  73. *
  74. * When the source and destination bitmaps are monochrome, a bit value of 0 represents a black pixel
  75. * and a bit value of 1 represents a white pixel. When the source and the destination bitmaps are color,
  76. * those colors are represented with red green blue (RGB) values.
  77. */
  78. public enum HwmfTernaryRasterOp {
  79. BLACKNESS(0x0000,0x0042,"0"),
  80. DPSOON(0x0001,0x0289,"DPSoon"),
  81. DPSONA(0x0002,0x0C89,"DPSona"),
  82. PSON(0x0003,0x00AA,"PSon"),
  83. SDPONA(0x0004,0x0C88,"SDPona"),
  84. DPON(0x0005,0x00A9,"DPon"),
  85. PDSXNON(0x0006,0x0865,"PDSxnon"),
  86. PDSAON(0x0007,0x02C5,"PDSaon"),
  87. SDPNAA(0x0008,0x0F08,"SDPnaa"),
  88. PDSXON(0x0009,0x0245,"PDSxon"),
  89. DPNA(0x000A,0x0329,"DPna"),
  90. PSDNAON(0x000B,0x0B2A,"PSDnaon"),
  91. SPNA(0x000C,0x0324,"SPna"),
  92. PDSNAON(0x000D,0x0B25,"PDSnaon"),
  93. PDSONON(0x000E,0x08A5,"PDSonon"),
  94. PN(0x000F,0x0001,"Pn"),
  95. PDSONA(0x0010,0x0C85,"PDSona"),
  96. NOTSRCERASE(0x0011,0x00A6,"DSon"),
  97. SDPXNON(0x0012,0x0868,"SDPxnon"),
  98. SDPAON(0x0013,0x02C8,"SDPaon"),
  99. DPSXNON(0x0014,0x0869,"DPSxnon"),
  100. DPSAON(0x0015,0x02C9,"DPSaon"),
  101. PSDPSANAXX(0x0016,0x5CCA,"PSDPSanaxx"),
  102. SSPXDSXAXN(0x0017,0x1D54,"SSPxDSxaxn"),
  103. SPXPDXA(0x0018,0x0D59,"SPxPDxa"),
  104. SDPSANAXN(0x0019,0x1CC8,"SDPSanaxn"),
  105. PDSPAOX(0x001A,0x06C5,"PDSPaox"),
  106. SDPSXAXN(0x001B,0x0768,"SDPSxaxn"),
  107. PSDPAOX(0x001C,0x06CA,"PSDPaox"),
  108. DSPDXAXN(0x001D,0x0766,"DSPDxaxn"),
  109. PDSOX(0x001E,0x01A5,"PDSox"),
  110. PDSOAN(0x001F,0x0385,"PDSoan"),
  111. DPSNAA(0x0020,0x0F09,"DPSnaa"),
  112. SDPXON(0x0021,0x0248,"SDPxon"),
  113. DSNA(0x0022,0x0326,"DSna"),
  114. SPDNAON(0x0023,0x0B24,"SPDnaon"),
  115. SPXDSXA(0x0024,0x0D55,"SPxDSxa"),
  116. PDSPANAXN(0x0025,0x1CC5,"PDSPanaxn"),
  117. SDPSAOX(0x0026,0x06C8,"SDPSaox"),
  118. SDPSXNOX(0x0027,0x1868,"SDPSxnox"),
  119. DPSXA(0x0028,0x0369,"DPSxa"),
  120. PSDPSAOXXN(0x0029,0x16CA,"PSDPSaoxxn"),
  121. DPSANA(0x002A,0x0CC9,"DPSana"),
  122. SSPXPDXAXN(0x002B,0x1D58,"SSPxPDxaxn"),
  123. SPDSOAX(0x002C,0x0784,"SPDSoax"),
  124. PSDNOX(0x002D,0x060A,"PSDnox"),
  125. PSDPXOX(0x002E,0x064A,"PSDPxox"),
  126. PSDNOAN(0x002F,0x0E2A,"PSDnoan"),
  127. PSNA(0x0030,0x032A,"PSna"),
  128. SDPNAON(0x0031,0x0B28,"SDPnaon"),
  129. SDPSOOX(0x0032,0x0688,"SDPSoox"),
  130. NOTSRCCOPY(0x0033,0x0008,"Sn"),
  131. SPDSAOX(0x0034,0x06C4,"SPDSaox"),
  132. SPDSXNOX(0x0035,0x1864,"SPDSxnox"),
  133. SDPOX(0x0036,0x01A8,"SDPox"),
  134. SDPOAN(0x0037,0x0388,"SDPoan"),
  135. PSDPOAX(0x0038,0x078A,"PSDPoax"),
  136. SPDNOX(0x0390,0x604,"SPDnox"),
  137. SPDSXOX(0x003A,0x0644,"SPDSxox"),
  138. SPDNOAN(0x003B,0x0E24,"SPDnoan"),
  139. PSX(0x003C,0x004A,"PSx"),
  140. SPDSONOX(0x003D,0x18A4,"SPDSonox"),
  141. SPDSNAOX(0x003E,0x1B24,"SPDSnaox"),
  142. PSAN(0x003F,0x00EA,"PSan"),
  143. PSDNAA(0x0040,0x0F0A,"PSDnaa"),
  144. DPSXON(0x0041,0x0249,"DPSxon"),
  145. SDXPDXA(0x0042,0x0D5D,"SDxPDxa"),
  146. SPDSANAXN(0x0043,0x1CC4,"SPDSanaxn"),
  147. SRCERASE(0x0044,0x0328,"SDna"),
  148. DPSNAON(0x0045,0x0B29,"DPSnaon"),
  149. DSPDAOX(0x0046,0x06C6,"DSPDaox"),
  150. PSDPXAXN(0x0047,0x076A,"PSDPxaxn"),
  151. SDPXA(0x0048,0x0368,"SDPxa"),
  152. PDSPDAOXXN(0x0049,0x16C5,"PDSPDaoxxn"),
  153. DPSDOAX(0x004A,0x0789,"DPSDoax"),
  154. PDSNOX(0x004B,0x0605,"PDSnox"),
  155. SDPANA(0x004C,0x0CC8,"SDPana"),
  156. SSPXDSXOXN(0x004D,0x1954,"SSPxDSxoxn"),
  157. PDSPXOX(0x004E,0x0645,"PDSPxox"),
  158. PDSNOAN(0x004F,0x0E25,"PDSnoan"),
  159. PDNA(0x0050,0x0325,"PDna"),
  160. DSPNAON(0x0051,0x0B26,"DSPnaon"),
  161. DPSDAOX(0x0052,0x06C9,"DPSDaox"),
  162. SPDSXAXN(0x0053,0x0764,"SPDSxaxn"),
  163. DPSONON(0x0054,0x08A9,"DPSonon"),
  164. DSTINVERT(0x0055,0x0009,"Dn"),
  165. DPSOX(0x0056,0x01A9,"DPSox"),
  166. DPSOAN(0x0005,0x70389,"DPSoan"),
  167. PDSPOAX(0x0058,0x0785,"PDSPoax"),
  168. DPSNOX(0x0059,0x0609,"DPSnox"),
  169. PATINVERT(0x005A,0x0049,"DPx"),
  170. DPSDONOX(0x005B,0x18A9,"DPSDonox"),
  171. DPSDXOX(0x005C,0x0649,"DPSDxox"),
  172. DPSNOAN(0x005D,0x0E29,"DPSnoan"),
  173. DPSDNAOX(0x005E,0x1B29,"DPSDnaox"),
  174. DPAN(0x005F,0x00E9,"DPan"),
  175. PDSXA(0x0060,0x0365,"PDSxa"),
  176. DSPDSAOXXN(0x0061,0x16C6,"DSPDSaoxxn"),
  177. DSPDOAX(0x0062,0x0786,"DSPDoax"),
  178. SDPNOX(0x0063,0x0608,"SDPnox"),
  179. SDPSOAX(0x0064,0x0788,"SDPSoax"),
  180. DSPNOX(0x0065,0x0606,"DSPnox"),
  181. SRCINVERT(0x0066,0x0046,"DSx"),
  182. SDPSONOX(0x0067,0x18A8,"SDPSonox"),
  183. DSPDSONOXXN(0x0068,0x58A6,"DSPDSonoxxn"),
  184. PDSXXN(0x0069,0x0145,"PDSxxn"),
  185. DPSAX(0x006A,0x01E9,"DPSax"),
  186. PSDPSOAXXN(0x006B,0x178A,"PSDPSoaxxn"),
  187. SDPAX(0x006C,0x01E8,"SDPax"),
  188. PDSPDOAXXN(0x006D,0x1785,"PDSPDoaxxn"),
  189. SDPSNOAX(0x006E,0x1E28,"SDPSnoax"),
  190. // PDXNAN(0x006F,0x0C65,"PDXnan"), // invalid combo
  191. PDSANA(0x0070,0x0CC5,"PDSana"),
  192. SSDXPDXAXN(0x0071,0x1D5C,"SSDxPDxaxn"),
  193. SDPSXOX(0x0072,0x0648,"SDPSxox"),
  194. SDPNOAN(0x0073,0x0E28,"SDPnoan"),
  195. DSPDXOX(0x0074,0x0646,"DSPDxox"),
  196. DSPNOAN(0x0075,0x0E26,"DSPnoan"),
  197. SDPSNAOX(0x0076,0x1B28,"SDPSnaox"),
  198. DSAN(0x0077,0x00E6,"DSan"),
  199. PDSAX(0x0078,0x01E5,"PDSax"),
  200. DSPDSOAXXN(0x0079,0x1786,"DSPDSoaxxn"),
  201. DPSDNOAX(0x007A,0x1E29,"DPSDnoax"),
  202. SDPXNAN(0x007B,0x0C68,"SDPxnan"),
  203. SPDSNOAX(0x007C,0x1E24,"SPDSnoax"),
  204. DPSXNAN(0x007D,0x0C69,"DPSxnan"),
  205. SPXDSXO(0x007E,0x0955,"SPxDSxo"),
  206. DPSAAN(0x007F,0x03C9,"DPSaan"),
  207. DPSAA(0x0080,0x03E9,"DPSaa"),
  208. SPXDSXON(0x0081,0x0975,"SPxDSxon"),
  209. DPSXNA(0x0082,0x0C49,"DPSxna"),
  210. SPDSNOAXN(0x0083,0x1E04,"SPDSnoaxn"),
  211. SDPXNA(0x0084,0x0C48,"SDPxna"),
  212. PDSPNOAXN(0x0085,0x1E05,"PDSPnoaxn"),
  213. DSPDSOAXX(0x0086,0x17A6,"DSPDSoaxx"),
  214. PDSAXN(0x0087,0x01C5,"PDSaxn"),
  215. SRCAND(0x0088,0x00C6,"DSa"),
  216. SDPSNAOXN(0x0089,0x1B08,"SDPSnaoxn"),
  217. DSPNOA(0x008A,0x0E06,"DSPnoa"),
  218. DSPDXOXN(0x008B,0x0666,"DSPDxoxn"),
  219. SDPNOA(0x008C,0x0E08,"SDPnoa"),
  220. SDPSXOXN(0x008D,0x0668,"SDPSxoxn"),
  221. SSDXPDXAX(0x008E,0x1D7C,"SSDxPDxax"),
  222. PDSANAN(0x008F,0x0CE5,"PDSanan"),
  223. PDSXNA(0x0090,0x0C45,"PDSxna"),
  224. SDPSNOAXN(0x0091,0x1E08,"SDPSnoaxn"),
  225. DPSDPOAXX(0x0092,0x17A9,"DPSDPoaxx"),
  226. SPDAXN(0x0093,0x01C4,"SPDaxn"),
  227. PSDPSOAXX(0x0094,0x17AA,"PSDPSoaxx"),
  228. DPSAXN(0x0095,0x01C9,"DPSaxn"),
  229. DPSXX(0x0096,0x0169,"DPSxx"),
  230. PSDPSONOXX(0x0097,0x588A,"PSDPSonoxx"),
  231. SDPSONOXN(0x0098,0x1888,"SDPSonoxn"),
  232. DSXN(0x0099,0x0066,"DSxn"),
  233. DPSNAX(0x009A,0x0709,"DPSnax"),
  234. SDPSOAXN(0x009B,0x07A8,"SDPSoaxn"),
  235. SPDNAX(0x009C,0x0704,"SPDnax"),
  236. DSPDOAXN(0x009D,0x07A6,"DSPDoaxn"),
  237. DSPDSAOXX(0x009E,0x16E6,"DSPDSaoxx"),
  238. PDSXAN(0x009F,0x0345,"PDSxan"),
  239. DPA(0x00A0,0x00C9,"DPa"),
  240. PDSPNAOXN(0x00A1,0x1B05,"PDSPnaoxn"),
  241. DPSNOA(0x00A2,0x0E09,"DPSnoa"),
  242. DPSDXOXN(0x00A3,0x0669,"DPSDxoxn"),
  243. PDSPONOXN(0x00A4,0x1885,"PDSPonoxn"),
  244. PDXN(0x00A5,0x0065,"PDxn"),
  245. DSPNAX(0x00A6,0x0706,"DSPnax"),
  246. PDSPOAXN(0x00A7,0x07A5,"PDSPoaxn"),
  247. DPSOA(0x00A8,0x03A9,"DPSoa"),
  248. DPSOXN(0x00A9,0x0189,"DPSoxn"),
  249. D(0x00AA,0x0029,"D"),
  250. DPSONO(0x00AB,0x0889,"DPSono"),
  251. SPDSXAX(0x00AC,0x0744,"SPDSxax"),
  252. DPSDAOXN(0x00AD,0x06E9,"DPSDaoxn"),
  253. DSPNAO(0x00AE,0x0B06,"DSPnao"),
  254. DPNO(0x00AF,0x0229,"DPno"),
  255. PDSNOA(0x00B0,0x0E05,"PDSnoa"),
  256. PDSPXOXN(0x00B1,0x0665,"PDSPxoxn"),
  257. SSPXDSXOX(0x00B2,0x1974,"SSPxDSxox"),
  258. SDPANAN(0x00B3,0x0CE8,"SDPanan"),
  259. PSDNAX(0x00B4,0x070A,"PSDnax"),
  260. DPSDOAXN(0x00B5,0x07A9,"DPSDoaxn"),
  261. DPSDPAOXX(0x00B6,0x16E9,"DPSDPaoxx"),
  262. SDPXAN(0x00B7,0x0348,"SDPxan"),
  263. PSDPXAX(0x00B8,0x074A,"PSDPxax"),
  264. DSPDAOXN(0x00B9,0x06E6,"DSPDaoxn"),
  265. DPSNAO(0x00BA,0x0B09,"DPSnao"),
  266. MERGEPAINT(0x00BB,0x0226,"DSno"),
  267. SPDSANAX(0x00BC,0x1CE4,"SPDSanax"),
  268. SDXPDXAN(0x00BD,0x0D7D,"SDxPDxan"),
  269. DPSXO(0x00BE,0x0269,"DPSxo"),
  270. DPSANO(0x00BF,0x08C9,"DPSano"),
  271. MERGECOPY(0x00C0,0x00CA,"PSa"),
  272. SPDSNAOXN(0x00C1,0x1B04,"SPDSnaoxn"),
  273. SPDSONOXN(0x00C2,0x1884,"SPDSonoxn"),
  274. PSXN(0x00C3,0x006A,"PSxn"),
  275. SPDNOA(0x00C4,0x0E04,"SPDnoa"),
  276. SPDSXOXN(0x00C5,0x0664,"SPDSxoxn"),
  277. SDPNAX(0x00C6,0x0708,"SDPnax"),
  278. PSDPOAXN(0x00C7,0x07AA,"PSDPoaxn"),
  279. SDPOA(0x00C8,0x03A8,"SDPoa"),
  280. SPDOXN(0x00C9,0x0184,"SPDoxn"),
  281. DPSDXAX(0x00CA,0x0749,"DPSDxax"),
  282. SPDSAOXN(0x00CB,0x06E4,"SPDSaoxn"),
  283. SRCCOPY(0x00CC,0x0020,"S"),
  284. SDPONO(0x00CD,0x0888,"SDPono"),
  285. SDPNAO(0x00CE,0x0B08,"SDPnao"),
  286. SPNO(0x00CF,0x0224,"SPno"),
  287. PSDNOA(0x00D0,0x0E0A,"PSDnoa"),
  288. PSDPXOXN(0x00D1,0x066A,"PSDPxoxn"),
  289. PDSNAX(0x00D2,0x0705,"PDSnax"),
  290. SPDSOAXN(0x00D3,0x07A4,"SPDSoaxn"),
  291. SSPXPDXAX(0x00D4,0x1D78,"SSPxPDxax"),
  292. DPSANAN(0x00D5,0x0CE9,"DPSanan"),
  293. PSDPSAOXX(0x00D6,0x16EA,"PSDPSaoxx"),
  294. DPSXAN(0x00D7,0x0349,"DPSxan"),
  295. PDSPXAX(0x00D8,0x0745,"PDSPxax"),
  296. SDPSAOXN(0x00D9,0x06E8,"SDPSaoxn"),
  297. DPSDANAX(0x00DA,0x1CE9,"DPSDanax"),
  298. SPXDSXAN(0x00DB,0x0D75,"SPxDSxan"),
  299. SPDNAO(0x00DC,0x0B04,"SPDnao"),
  300. SDNO(0x00DD,0x0228,"SDno"),
  301. SDPXO(0x00DE,0x0268,"SDPxo"),
  302. SDPANO(0x00DF,0x08C8,"SDPano"),
  303. PDSOA(0x00E0,0x03A5,"PDSoa"),
  304. PDSOXN(0x00E1,0x0185,"PDSoxn"),
  305. DSPDXAX(0x00E2,0x0746,"DSPDxax"),
  306. PSDPAOXN(0x00E3,0x06EA,"PSDPaoxn"),
  307. SDPSXAX(0x00E4,0x0748,"SDPSxax"),
  308. PDSPAOXN(0x00E5,0x06E5,"PDSPaoxn"),
  309. SDPSANAX(0x00E6,0x1CE8,"SDPSanax"),
  310. SPXPDXAN(0x00E7,0x0D79,"SPxPDxan"),
  311. SSPXDSXAX(0x00E8,0x1D74,"SSPxDSxax"),
  312. DSPDSANAXXN(0x00E9,0x5CE6,"DSPDSanaxxn"),
  313. DPSAO(0x00EA,0x02E9,"DPSao"),
  314. DPSXNO(0x00EB,0x0849,"DPSxno"),
  315. SDPAO(0x00EC,0x02E8,"SDPao"),
  316. SDPXNO(0x00ED,0x0848,"SDPxno"),
  317. SRCPAINT(0x00EE,0x0086,"DSo"),
  318. SDPNOO(0x00EF,0x0A08,"SDPnoo"),
  319. PATCOPY(0x00F0,0x0021,"P"),
  320. PDSONO(0x00F1,0x0885,"PDSono"),
  321. PDSNAO(0x00F2,0x0B05,"PDSnao"),
  322. PSNO(0x00F3,0x022A,"PSno"),
  323. PSDNAO(0x00F4,0x0B0A,"PSDnao"),
  324. PDNO(0x00F5,0x0225,"PDno"),
  325. PDSXO(0x00F6,0x0265,"PDSxo"),
  326. PDSANO(0x00F7,0x08C5,"PDSano"),
  327. PDSAO(0x00F8,0x02E5,"PDSao"),
  328. PDSXNO(0x00F9,0x0845,"PDSxno"),
  329. DPO(0x00FA,0x0089,"DPo"),
  330. PATPAINT(0x00FB,0x0A09,"DPSnoo"),
  331. PSO(0x00FC,0x008A,"PSo"),
  332. PSDNOO(0x00FD,0x0A0A,"PSDnoo"),
  333. DPSOO(0x00FE,0x02A9,"DPSoo"),
  334. WHITENESS(0x00FF,0x0062,"1");
  335. int opIndex;
  336. int opCode;
  337. String opCmd;
  338. HwmfTernaryRasterOp(int opIndex, int opCode, String opCmd) {
  339. this.opIndex=opIndex;
  340. this.opCode=opCode;
  341. this.opCmd=opCmd;
  342. }
  343. public static HwmfTernaryRasterOp valueOf(int opIndex) {
  344. for (HwmfTernaryRasterOp bb : HwmfTernaryRasterOp.values()) {
  345. if (bb.opIndex == opIndex) {
  346. return bb;
  347. }
  348. }
  349. return null;
  350. }
  351. public String describeCmd() {
  352. String stack[] = new String[10];
  353. int stackPnt = 0;
  354. for (char c : opCmd.toCharArray()) {
  355. switch (c) {
  356. case 'S':
  357. case 'D':
  358. case 'P':
  359. stack[stackPnt++] = ""+c;
  360. break;
  361. case 'n':
  362. stack[stackPnt-1] = "not("+stack[stackPnt-1]+")";
  363. break;
  364. case 'a':
  365. stack[stackPnt-2] = "("+stack[stackPnt-1]+" and "+stack[stackPnt-2]+")";
  366. stackPnt--;
  367. break;
  368. case 'o':
  369. stack[stackPnt-2] = "("+stack[stackPnt-1]+" or "+stack[stackPnt-2]+")";
  370. stackPnt--;
  371. break;
  372. case 'x':
  373. stack[stackPnt-2] = "("+stack[stackPnt-1]+" xor "+stack[stackPnt-2]+")";
  374. stackPnt--;
  375. break;
  376. case '1':
  377. stack[stackPnt++] = "all white";
  378. break;
  379. case '0':
  380. stack[stackPnt++] = "all black";
  381. break;
  382. default:
  383. throw new RuntimeException("unknown cmd '"+c+"'.");
  384. }
  385. }
  386. return stack[--stackPnt];
  387. }
  388. }