Leaked source code of windows server 2003
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.

608 lines
13 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // DITH666.H - full color dither (to a palette with 6 red, 6 green 6 blue
  4. // levels)
  5. //
  6. //////////////////////////////////////////////////////////////////////////////
  7. #define HSIZE 4 // matrix size is 4x4
  8. #define SEG666 _based(_segname("DITH666")) // segment containing tables
  9. #define SEGXXX _based(_segname("_CODE")) // segment containing init tables
  10. //////////////////////////////////////////////////////////////////////////////
  11. //
  12. // dither table for 256 level dither (RGB 24 or 32)
  13. //
  14. // total table size is 12k
  15. //
  16. //////////////////////////////////////////////////////////////////////////////
  17. #define DITH256(x,y,r,g,b) aTranslate666[ \
  18. 1 * (r/51 + (r%51 > aHalftone4x4[x][y])) + \
  19. 6 * (g/51 + (g%51 > aHalftone4x4[x][y])) + \
  20. 36 * (b/51 + (b%51 > aHalftone4x4[x][y]))]
  21. #define DITH8(x,y,r,g,b) aTranslate666[ \
  22. aHalftone8[0][(x)&3][(y)&3][(r)] +\
  23. aHalftone8[1][(x)&3][(y)&3][(g)] +\
  24. aHalftone8[2][(x)&3][(y)&3][(b)] ]
  25. char unsigned SEG666 aHalftone8[3][4][4][256] = {(BYTE)-1};
  26. #if 1
  27. static char unsigned const SEGXXX aHalftone4x4[4][4] =
  28. {
  29. 0, 25, 6, 31,
  30. 38, 12, 44, 19,
  31. 9, 35, 3, 28,
  32. 47, 22, 41, 15
  33. };
  34. #else
  35. static char unsigned const SEGXXX aHalftone4x4[4][4] =
  36. {
  37. 41, 3, 9, 28,
  38. 35, 15, 22, 47,
  39. 6, 25, 38, 0,
  40. 19, 44, 31, 12
  41. };
  42. #endif
  43. //////////////////////////////////////////////////////////////////////////////
  44. //
  45. // dither table for 32 level dither (RGB 555 or 565)
  46. //
  47. // total table size is 12k
  48. //
  49. //////////////////////////////////////////////////////////////////////////////
  50. #define d62(n) (((n) * 10) / 62) // n / 6.2
  51. #define m62(n) ((n) * 1000 / 62 - d62(n) * 100) // n % 6.2
  52. #define DITH31(x,y,r,g,b) aTranslate666[ \
  53. 1 * (d62(r) + (m62(r) > (UINT)aHalftone2x2[x][y])) + \
  54. 6 * (d62(g) + (m62(g) > (UINT)aHalftone2x2[x][y])) + \
  55. 36 * (d62(b) + (m62(b) > (UINT)aHalftone2x2[x][y]))]
  56. static char SEGXXX aHalftone2x2[2][2] =
  57. {
  58. 0, 99,
  59. 66,33,
  60. };
  61. #ifdef USE_C
  62. #define DITH5(x,y,rgb) aTranslate666[ \
  63. aHalftone5[0][(x)&3][(y)&3][((rgb)>>8)&0xFF] +\
  64. aHalftone5[1][(x)&3][(y)&3][((rgb)>>5)&0xFF] +\
  65. aHalftone5[2][(x)&3][(y)&3][((rgb)>>0)&0xFF] ]
  66. char unsigned SEG666 aHalftone5[3][4][4][256] = {(BYTE)-1};
  67. #if 0
  68. static char unsigned const SEGXXX aHalftone4x4_5[4][4] =
  69. {
  70. 0,3,0,3,
  71. 4,1,4,1,
  72. 0,3,0,3,
  73. 4,1,4,1
  74. };
  75. #else
  76. static char SEGXXX aHalftone4x4_5[4][4] =
  77. {
  78. 0,3,2,3,
  79. 2,4,0,3,
  80. 2,0,4,1,
  81. 4,1,2,1
  82. };
  83. #endif
  84. #endif
  85. //////////////////////////////////////////////////////////////////////////////
  86. //
  87. // translate table from a 666 index to a foreground palette index
  88. //
  89. //////////////////////////////////////////////////////////////////////////////
  90. char unsigned SEG666 aTranslate666[216] =
  91. {
  92. 0,
  93. 29,
  94. 30,
  95. 31,
  96. 32,
  97. 249,
  98. 33,
  99. 34,
  100. 35,
  101. 36,
  102. 37,
  103. 38,
  104. 39,
  105. 40,
  106. 41,
  107. 42,
  108. 43,
  109. 44,
  110. 45,
  111. 46,
  112. 47,
  113. 48,
  114. 49,
  115. 50,
  116. 51,
  117. 52,
  118. 53,
  119. 54,
  120. 55,
  121. 56,
  122. 250,
  123. 250,
  124. 57,
  125. 58,
  126. 59,
  127. 251,
  128. 60,
  129. 61,
  130. 62,
  131. 63,
  132. 64,
  133. 65,
  134. 66,
  135. 67,
  136. 68,
  137. 69,
  138. 70,
  139. 71,
  140. 72,
  141. 73,
  142. 74,
  143. 75,
  144. 76,
  145. 77,
  146. 78,
  147. 79,
  148. 80,
  149. 81,
  150. 82,
  151. 83,
  152. 84,
  153. 85,
  154. 86,
  155. 87,
  156. 88,
  157. 89,
  158. 250,
  159. 90,
  160. 91,
  161. 92,
  162. 93,
  163. 94,
  164. 95,
  165. 96,
  166. 97,
  167. 98,
  168. 99,
  169. 100,
  170. 101,
  171. 102,
  172. 103,
  173. 104,
  174. 105,
  175. 106,
  176. 107,
  177. 108,
  178. 109,
  179. 110,
  180. 111,
  181. 227,
  182. 112,
  183. 113,
  184. 114,
  185. 115,
  186. 116,
  187. 117,
  188. 118,
  189. 119,
  190. 151,
  191. 120,
  192. 121,
  193. 122,
  194. 123,
  195. 124,
  196. 228,
  197. 125,
  198. 126,
  199. 229,
  200. 133,
  201. 162,
  202. 135,
  203. 131,
  204. 132,
  205. 137,
  206. 166,
  207. 134,
  208. 140,
  209. 130,
  210. 136,
  211. 143,
  212. 138,
  213. 139,
  214. 174,
  215. 141,
  216. 142,
  217. 177,
  218. 129,
  219. 144,
  220. 145,
  221. 146,
  222. 147,
  223. 148,
  224. 149,
  225. 150,
  226. 157,
  227. 152,
  228. 153,
  229. 154,
  230. 155,
  231. 156,
  232. 192,
  233. 158,
  234. 159,
  235. 160,
  236. 161,
  237. 196,
  238. 163,
  239. 164,
  240. 165,
  241. 127,
  242. 199,
  243. 167,
  244. 168,
  245. 169,
  246. 170,
  247. 171,
  248. 172,
  249. 173,
  250. 207,
  251. 175,
  252. 176,
  253. 210,
  254. 178,
  255. 179,
  256. 180,
  257. 181,
  258. 182,
  259. 183,
  260. 184,
  261. 185,
  262. 186,
  263. 187,
  264. 188,
  265. 189,
  266. 190,
  267. 191,
  268. 224,
  269. 193,
  270. 194,
  271. 195,
  272. 252,
  273. 252,
  274. 197,
  275. 198,
  276. 128,
  277. 253,
  278. 252,
  279. 200,
  280. 201,
  281. 202,
  282. 203,
  283. 204,
  284. 205,
  285. 206,
  286. 230,
  287. 208,
  288. 209,
  289. 231,
  290. 211,
  291. 212,
  292. 213,
  293. 214,
  294. 215,
  295. 216,
  296. 217,
  297. 218,
  298. 219,
  299. 220,
  300. 221,
  301. 222,
  302. 254,
  303. 223,
  304. 232,
  305. 225,
  306. 226,
  307. 255,
  308. };
  309. /*-----------------------------------------------------------------------
  310. | mspal.h
  311. |
  312. | Standard MS Apps Palette. v 1.01
  313. |
  314. | #include this file in the same file as HPalCreateAppPalette
  315. |
  316. | WARNING: Generated File! DO NOT EDIT!
  317. | WARNING: Palette MUST be created with HpalCreateAppPalette
  318. |
  319. ---------------------------------------------------------------WESC----*/
  320. unsigned char SEGXXX pal666[256][3] =
  321. {
  322. // R G B
  323. {0x00, 0x00, 0x00}, // 0 Sys Black gray 0
  324. {0x80, 0x00, 0x00}, // 1 Sys Dk Red
  325. {0x00, 0x80, 0x00}, // 2 Sys Dk Green
  326. {0x80, 0x80, 0x00}, // 3 Sys Dk Yellow
  327. {0x00, 0x00, 0x80}, // 4 Sys Dk Blue
  328. {0x80, 0x00, 0x80}, // 5 Sys Dk Violet
  329. {0x00, 0x80, 0x80}, // 6 Sys Dk Cyan
  330. {0xc0, 0xc0, 0xc0}, // 7 Sys Lt Grey gray 192
  331. {0xc0, 0xdc, 0xc0}, // 8 Sys 8
  332. {0xa6, 0xca, 0xf0}, // 9 Sys 9 (the first 10 are fixed by Windows)
  333. {0x04, 0x04, 0x04}, // 10 gray 4
  334. {0x08, 0x08, 0x08}, // 11 gray 8
  335. {0x0c, 0x0c, 0x0c}, // 12 gray 12
  336. {0x11, 0x11, 0x11}, // 13 gray 17
  337. {0x16, 0x16, 0x16}, // 14 gray 22
  338. {0x1c, 0x1c, 0x1c}, // 15 gray 28
  339. {0x22, 0x22, 0x22}, // 16 gray 34
  340. {0x29, 0x29, 0x29}, // 17 gray 41
  341. {0x55, 0x55, 0x55}, // 18 swapped so inversions look good gray 85
  342. {0x4d, 0x4d, 0x4d}, // 19 swapped so inversions look good gray 77
  343. {0x42, 0x42, 0x42}, // 20 swapped so inversions look good gray 66
  344. {0x39, 0x39, 0x39}, // 21 swapped so inversions look good gray 57
  345. {0x81, 0x81, 0x81}, // 22 Sys Dk Grey repeat gray 128
  346. {0x81, 0x00, 0x00}, // 23 Sys Dk Red repeat
  347. {0x00, 0x81, 0x00}, // 24 Sys Dk Green repeat
  348. {0x81, 0x81, 0x00}, // 25 Sys Dk Yellow repeat
  349. {0x00, 0x00, 0x81}, // 26 Sys Dk Blue repeat
  350. {0x81, 0x00, 0x81}, // 27 Sys Dk Violet repeat
  351. {0x00, 0x81, 0x81}, // 28 Sys Dk Cyan repeat
  352. {0x33, 0x00, 0x00}, // 29
  353. {0x66, 0x00, 0x00}, // 30
  354. {0x99, 0x00, 0x00}, // 31
  355. {0xcc, 0x00, 0x00}, // 32
  356. {0x00, 0x33, 0x00}, // 33
  357. {0x33, 0x33, 0x00}, // 34
  358. {0x66, 0x33, 0x00}, // 35
  359. {0x99, 0x33, 0x00}, // 36
  360. {0xcc, 0x33, 0x00}, // 37
  361. {0xff, 0x33, 0x00}, // 38
  362. {0x00, 0x66, 0x00}, // 39
  363. {0x33, 0x66, 0x00}, // 40
  364. {0x66, 0x66, 0x00}, // 41
  365. {0x99, 0x66, 0x00}, // 42
  366. {0xcc, 0x66, 0x00}, // 43
  367. {0xff, 0x66, 0x00}, // 44
  368. {0x00, 0x99, 0x00}, // 45
  369. {0x33, 0x99, 0x00}, // 46
  370. {0x66, 0x99, 0x00}, // 47
  371. {0x99, 0x99, 0x00}, // 48
  372. {0xcc, 0x99, 0x00}, // 49
  373. {0xff, 0x99, 0x00}, // 50
  374. {0x00, 0xcc, 0x00}, // 51
  375. {0x33, 0xcc, 0x00}, // 52
  376. {0x66, 0xcc, 0x00}, // 53
  377. {0x99, 0xcc, 0x00}, // 54
  378. {0xcc, 0xcc, 0x00}, // 55
  379. {0xff, 0xcc, 0x00}, // 56
  380. {0x66, 0xff, 0x00}, // 57
  381. {0x99, 0xff, 0x00}, // 58
  382. {0xcc, 0xff, 0x00}, // 59
  383. {0x00, 0x00, 0x33}, // 60
  384. {0x33, 0x00, 0x33}, // 61
  385. {0x66, 0x00, 0x33}, // 62
  386. {0x99, 0x00, 0x33}, // 63
  387. {0xcc, 0x00, 0x33}, // 64
  388. {0xff, 0x00, 0x33}, // 65
  389. {0x00, 0x33, 0x33}, // 66
  390. {0x33, 0x33, 0x33}, // 67 gray 51
  391. {0x66, 0x33, 0x33}, // 68
  392. {0x99, 0x33, 0x33}, // 69
  393. {0xcc, 0x33, 0x33}, // 70
  394. {0xff, 0x33, 0x33}, // 71
  395. {0x00, 0x66, 0x33}, // 72
  396. {0x33, 0x66, 0x33}, // 73
  397. {0x66, 0x66, 0x33}, // 74
  398. {0x99, 0x66, 0x33}, // 75
  399. {0xcc, 0x66, 0x33}, // 76
  400. {0xff, 0x66, 0x33}, // 77
  401. {0x00, 0x99, 0x33}, // 78
  402. {0x33, 0x99, 0x33}, // 79
  403. {0x66, 0x99, 0x33}, // 80
  404. {0x99, 0x99, 0x33}, // 81
  405. {0xcc, 0x99, 0x33}, // 82
  406. {0xff, 0x99, 0x33}, // 83
  407. {0x00, 0xcc, 0x33}, // 84
  408. {0x33, 0xcc, 0x33}, // 85
  409. {0x66, 0xcc, 0x33}, // 86
  410. {0x99, 0xcc, 0x33}, // 87
  411. {0xcc, 0xcc, 0x33}, // 88
  412. {0xff, 0xcc, 0x33}, // 89
  413. {0x33, 0xff, 0x33}, // 90
  414. {0x66, 0xff, 0x33}, // 91
  415. {0x99, 0xff, 0x33}, // 92
  416. {0xcc, 0xff, 0x33}, // 93
  417. {0xff, 0xff, 0x33}, // 94
  418. {0x00, 0x00, 0x66}, // 95
  419. {0x33, 0x00, 0x66}, // 96
  420. {0x66, 0x00, 0x66}, // 97
  421. {0x99, 0x00, 0x66}, // 98
  422. {0xcc, 0x00, 0x66}, // 99
  423. {0xff, 0x00, 0x66}, // 100
  424. {0x00, 0x33, 0x66}, // 101
  425. {0x33, 0x33, 0x66}, // 102
  426. {0x66, 0x33, 0x66}, // 103
  427. {0x99, 0x33, 0x66}, // 104
  428. {0xcc, 0x33, 0x66}, // 105
  429. {0xff, 0x33, 0x66}, // 106
  430. {0x00, 0x66, 0x66}, // 107
  431. {0x33, 0x66, 0x66}, // 108
  432. {0x66, 0x66, 0x66}, // 109 gray 102
  433. {0x99, 0x66, 0x66}, // 110
  434. {0xcc, 0x66, 0x66}, // 111
  435. {0x00, 0x99, 0x66}, // 112
  436. {0x33, 0x99, 0x66}, // 113
  437. {0x66, 0x99, 0x66}, // 114
  438. {0x99, 0x99, 0x66}, // 115
  439. {0xcc, 0x99, 0x66}, // 116
  440. {0xff, 0x99, 0x66}, // 117
  441. {0x00, 0xcc, 0x66}, // 118
  442. {0x33, 0xcc, 0x66}, // 119
  443. {0x99, 0xcc, 0x66}, // 120
  444. {0xcc, 0xcc, 0x66}, // 121
  445. {0xff, 0xcc, 0x66}, // 122
  446. {0x00, 0xff, 0x66}, // 123
  447. {0x33, 0xff, 0x66}, // 124
  448. {0x99, 0xff, 0x66}, // 125
  449. {0xcc, 0xff, 0x66}, // 126
  450. {0xff, 0x00, 0xcc}, // 127
  451. {0xcc, 0x00, 0xff}, // 128
  452. {0x00, 0x99, 0x99}, // 129
  453. {0x99, 0x33, 0x99}, // 130
  454. {0x99, 0x00, 0x99}, // 131
  455. {0xcc, 0x00, 0x99}, // 132
  456. {0x00, 0x00, 0x99}, // 133
  457. {0x33, 0x33, 0x99}, // 134
  458. {0x66, 0x00, 0x99}, // 135
  459. {0xcc, 0x33, 0x99}, // 136
  460. {0xff, 0x00, 0x99}, // 137
  461. {0x00, 0x66, 0x99}, // 138
  462. {0x33, 0x66, 0x99}, // 139
  463. {0x66, 0x33, 0x99}, // 140
  464. {0x99, 0x66, 0x99}, // 141
  465. {0xcc, 0x66, 0x99}, // 142
  466. {0xff, 0x33, 0x99}, // 143
  467. {0x33, 0x99, 0x99}, // 144
  468. {0x66, 0x99, 0x99}, // 145
  469. {0x99, 0x99, 0x99}, // 146 gray 153
  470. {0xcc, 0x99, 0x99}, // 147
  471. {0xff, 0x99, 0x99}, // 148
  472. {0x00, 0xcc, 0x99}, // 149
  473. {0x33, 0xcc, 0x99}, // 150
  474. {0x66, 0xcc, 0x66}, // 151
  475. {0x99, 0xcc, 0x99}, // 152
  476. {0xcc, 0xcc, 0x99}, // 153
  477. {0xff, 0xcc, 0x99}, // 154
  478. {0x00, 0xff, 0x99}, // 155
  479. {0x33, 0xff, 0x99}, // 156
  480. {0x66, 0xcc, 0x99}, // 157
  481. {0x99, 0xff, 0x99}, // 158
  482. {0xcc, 0xff, 0x99}, // 159
  483. {0xff, 0xff, 0x99}, // 160
  484. {0x00, 0x00, 0xcc}, // 161
  485. {0x33, 0x00, 0x99}, // 162
  486. {0x66, 0x00, 0xcc}, // 163
  487. {0x99, 0x00, 0xcc}, // 164
  488. {0xcc, 0x00, 0xcc}, // 165
  489. {0x00, 0x33, 0x99}, // 166
  490. {0x33, 0x33, 0xcc}, // 167
  491. {0x66, 0x33, 0xcc}, // 168
  492. {0x99, 0x33, 0xcc}, // 169
  493. {0xcc, 0x33, 0xcc}, // 170
  494. {0xff, 0x33, 0xcc}, // 171
  495. {0x00, 0x66, 0xcc}, // 172
  496. {0x33, 0x66, 0xcc}, // 173
  497. {0x66, 0x66, 0x99}, // 174
  498. {0x99, 0x66, 0xcc}, // 175
  499. {0xcc, 0x66, 0xcc}, // 176
  500. {0xff, 0x66, 0x99}, // 177
  501. {0x00, 0x99, 0xcc}, // 178
  502. {0x33, 0x99, 0xcc}, // 179
  503. {0x66, 0x99, 0xcc}, // 180
  504. {0x99, 0x99, 0xcc}, // 181
  505. {0xcc, 0x99, 0xcc}, // 182
  506. {0xff, 0x99, 0xcc}, // 183
  507. {0x00, 0xcc, 0xcc}, // 184
  508. {0x33, 0xcc, 0xcc}, // 185
  509. {0x66, 0xcc, 0xcc}, // 186
  510. {0x99, 0xcc, 0xcc}, // 187
  511. {0xcc, 0xcc, 0xcc}, // 188 gray 204
  512. {0xff, 0xcc, 0xcc}, // 189
  513. {0x00, 0xff, 0xcc}, // 190
  514. {0x33, 0xff, 0xcc}, // 191
  515. {0x66, 0xff, 0x99}, // 192
  516. {0x99, 0xff, 0xcc}, // 193
  517. {0xcc, 0xff, 0xcc}, // 194
  518. {0xff, 0xff, 0xcc}, // 195
  519. {0x33, 0x00, 0xcc}, // 196
  520. {0x66, 0x00, 0xff}, // 197
  521. {0x99, 0x00, 0xff}, // 198
  522. {0x00, 0x33, 0xcc}, // 199
  523. {0x33, 0x33, 0xff}, // 200
  524. {0x66, 0x33, 0xff}, // 201
  525. {0x99, 0x33, 0xff}, // 202
  526. {0xcc, 0x33, 0xff}, // 203
  527. {0xff, 0x33, 0xff}, // 204
  528. {0x00, 0x66, 0xff}, // 205
  529. {0x33, 0x66, 0xff}, // 206
  530. {0x66, 0x66, 0xcc}, // 207
  531. {0x99, 0x66, 0xff}, // 208
  532. {0xcc, 0x66, 0xff}, // 209
  533. {0xff, 0x66, 0xcc}, // 210
  534. {0x00, 0x99, 0xff}, // 211
  535. {0x33, 0x99, 0xff}, // 212
  536. {0x66, 0x99, 0xff}, // 213
  537. {0x99, 0x99, 0xff}, // 214
  538. {0xcc, 0x99, 0xff}, // 215
  539. {0xff, 0x99, 0xff}, // 216
  540. {0x00, 0xcc, 0xff}, // 217
  541. {0x33, 0xcc, 0xff}, // 218
  542. {0x66, 0xcc, 0xff}, // 219
  543. {0x99, 0xcc, 0xff}, // 220
  544. {0xcc, 0xcc, 0xff}, // 221
  545. {0xff, 0xcc, 0xff}, // 222
  546. {0x33, 0xff, 0xff}, // 223
  547. {0x66, 0xff, 0xcc}, // 224
  548. {0x99, 0xff, 0xff}, // 225
  549. {0xcc, 0xff, 0xff}, // 226
  550. {0xff, 0x66, 0x66}, // 227
  551. {0x66, 0xff, 0x66}, // 228
  552. {0xff, 0xff, 0x66}, // 229
  553. {0x66, 0x66, 0xff}, // 230
  554. {0xff, 0x66, 0xff}, // 231
  555. {0x66, 0xff, 0xff}, // 232
  556. {0xc1, 0xc1, 0xc1}, // 233 Sys Dk Grey repeat inversion gray 192
  557. {0x5f, 0x5f, 0x5f}, // 234 gray 95
  558. {0x77, 0x77, 0x77}, // 235 gray 119
  559. {0x86, 0x86, 0x86}, // 236 gray 134
  560. {0x96, 0x96, 0x96}, // 237 gray 150
  561. {0xcb, 0xcb, 0xcb}, // 238 gray 203
  562. {0xb2, 0xb2, 0xb2}, // 239 gray 178
  563. {0xd7, 0xd7, 0xd7}, // 240 gray 215
  564. {0xdd, 0xdd, 0xdd}, // 241 gray 221
  565. {0xe3, 0xe3, 0xe3}, // 242 gray 227
  566. {0xea, 0xea, 0xea}, // 243 gray 234
  567. {0xf1, 0xf1, 0xf1}, // 244 gray 241
  568. {0xf8, 0xf8, 0xf8}, // 245 gray 248
  569. {0xff, 0xfb, 0xf0}, // 246 Sys Reserved
  570. {0xa0, 0xa0, 0xa4}, // 247 Sys Reserved
  571. {0x80, 0x80, 0x80}, // 248 Sys Lt Gray gray 128
  572. {0xff, 0x00, 0x00}, // 249 Sys Red
  573. {0x00, 0xff, 0x00}, // 250 Sys Green
  574. {0xff, 0xff, 0x00}, // 251 Sys Yellow
  575. {0x00, 0x00, 0xff}, // 252 Sys Blue
  576. {0xff, 0x00, 0xff}, // 253 Sys Violet
  577. {0x00, 0xff, 0xff}, // 254 Sys Cyan
  578. {0xff, 0xff, 0xff} // 255 Sys White gray 255
  579. };