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.

705 lines
37 KiB

  1. /****************************************************************************/
  2. /* */
  3. /* abdcom.c */
  4. /* */
  5. /* Copyright (c) Data Connection Limited 1998 */
  6. /* */
  7. /* */
  8. /* Bitmap decompression routine and macros for 16 and 24bpp protocol */
  9. /* */
  10. /****************************************************************************/
  11. // #ifdef BC_TRACE
  12. // #define BCTRACE TRC_DBG
  13. // #else
  14. #define BCTRACE(string)
  15. // #endif
  16. /****************************************************************************/
  17. /* We use the same helper macros as the 8bpp code except for STORE_FGBG. */
  18. /****************************************************************************/
  19. /****************************************************************************/
  20. /* Macro to store an FGBG image at destbuf */
  21. /* */
  22. /* xorPel is either the value 0 or an expression containing the local */
  23. /* variable destbuf. */
  24. /* */
  25. /* THIS MEANS THAT xorPel HAS A DIFFERENT VALUE EVERY TIME destbuf IS */
  26. /* CHANGED. */
  27. /* */
  28. /* fgPel is a BC_PIXEL and the FG color to XOR with xorbyte */
  29. /* fgbgChar is a bitmask telling which color to put where */
  30. /* */
  31. /* This macro expects that the function defines pDst, pEndDst, hr */
  32. /* If there is not enough data to write the full run, this will set error */
  33. /* and quit */
  34. /****************************************************************************/
  35. #undef STORE_FGBG
  36. #define STORE_FGBG(xorPelIn, fgbgChar, fgPel, bits) \
  37. { \
  38. UINT numbits = bits; \
  39. BC_PIXEL xorPel; \
  40. BD_CHECK_WRITE_N_BYTES( destbuf, pEndDst, max(1, min(numbits, 8)) * BC_PIXEL_LEN, hr ) \
  41. \
  42. xorPel = BC_GET_PIXEL(xorPelIn); \
  43. if (fgbgChar & 0x01) \
  44. { \
  45. BC_SET_PIXEL(destbuf, xorPel ^ fgPel); \
  46. } \
  47. else \
  48. { \
  49. BC_SET_PIXEL(destbuf, xorPel); \
  50. } \
  51. BC_TO_NEXT_PIXEL(destbuf); \
  52. \
  53. if (--numbits > 0) \
  54. { \
  55. xorPel = BC_GET_PIXEL(xorPelIn); \
  56. if (fgbgChar & 0x02) \
  57. { \
  58. BC_SET_PIXEL(destbuf, xorPel ^ fgPel); \
  59. } \
  60. else \
  61. { \
  62. BC_SET_PIXEL(destbuf, xorPel) \
  63. } \
  64. BC_TO_NEXT_PIXEL(destbuf); \
  65. \
  66. if (--numbits > 0) \
  67. { \
  68. xorPel = BC_GET_PIXEL(xorPelIn); \
  69. if (fgbgChar & 0x04) \
  70. { \
  71. BC_SET_PIXEL(destbuf, xorPel ^ fgPel); \
  72. } \
  73. else \
  74. { \
  75. BC_SET_PIXEL(destbuf, xorPel) \
  76. } \
  77. BC_TO_NEXT_PIXEL(destbuf); \
  78. \
  79. if (--numbits > 0) \
  80. { \
  81. xorPel = BC_GET_PIXEL(xorPelIn); \
  82. if (fgbgChar & 0x08) \
  83. { \
  84. BC_SET_PIXEL(destbuf, xorPel ^ fgPel); \
  85. } \
  86. else \
  87. { \
  88. BC_SET_PIXEL(destbuf, xorPel); \
  89. } \
  90. BC_TO_NEXT_PIXEL(destbuf); \
  91. \
  92. if (--numbits > 0) \
  93. { \
  94. xorPel = BC_GET_PIXEL(xorPelIn); \
  95. if (fgbgChar & 0x10) \
  96. { \
  97. BC_SET_PIXEL(destbuf, xorPel ^ fgPel); \
  98. } \
  99. else \
  100. { \
  101. BC_SET_PIXEL(destbuf, xorPel); \
  102. } \
  103. BC_TO_NEXT_PIXEL(destbuf); \
  104. \
  105. if (--numbits > 0) \
  106. { \
  107. xorPel = BC_GET_PIXEL(xorPelIn); \
  108. if (fgbgChar & 0x20) \
  109. { \
  110. BC_SET_PIXEL(destbuf, xorPel ^ fgPel); \
  111. } \
  112. else \
  113. { \
  114. BC_SET_PIXEL(destbuf, xorPel); \
  115. } \
  116. BC_TO_NEXT_PIXEL(destbuf); \
  117. \
  118. if (--numbits > 0) \
  119. { \
  120. xorPel = BC_GET_PIXEL(xorPelIn); \
  121. if (fgbgChar & 0x40) \
  122. { \
  123. BC_SET_PIXEL(destbuf, xorPel ^ fgPel); \
  124. } \
  125. else \
  126. { \
  127. BC_SET_PIXEL(destbuf, xorPel); \
  128. } \
  129. BC_TO_NEXT_PIXEL(destbuf); \
  130. \
  131. if (--numbits > 0) \
  132. { \
  133. xorPel = BC_GET_PIXEL(xorPelIn); \
  134. if (fgbgChar & 0x80) \
  135. { \
  136. BC_SET_PIXEL(destbuf, xorPel ^ fgPel); \
  137. } \
  138. else \
  139. { \
  140. BC_SET_PIXEL(destbuf, xorPel); \
  141. } \
  142. BC_TO_NEXT_PIXEL(destbuf); \
  143. } \
  144. } \
  145. } \
  146. } \
  147. } \
  148. } \
  149. } \
  150. }
  151. #define STORE_LINE1_FGBG(fgbgChar, fgPel, bits) \
  152. { \
  153. UINT numbits = bits; \
  154. BD_CHECK_WRITE_N_BYTES( destbuf, pEndDst, max(1, min(numbits, 8)) * BC_PIXEL_LEN, hr ) \
  155. \
  156. if (fgbgChar & 0x01) \
  157. { \
  158. BC_SET_PIXEL(destbuf, fgPel); \
  159. } \
  160. else \
  161. { \
  162. BC_SET_PIXEL(destbuf, 0); \
  163. } \
  164. BC_TO_NEXT_PIXEL(destbuf); \
  165. \
  166. if (--numbits > 0) \
  167. { \
  168. if (fgbgChar & 0x02) \
  169. { \
  170. BC_SET_PIXEL(destbuf, fgPel); \
  171. } \
  172. else \
  173. { \
  174. BC_SET_PIXEL(destbuf, 0) \
  175. } \
  176. BC_TO_NEXT_PIXEL(destbuf); \
  177. \
  178. if (--numbits > 0) \
  179. { \
  180. if (fgbgChar & 0x04) \
  181. { \
  182. BC_SET_PIXEL(destbuf, fgPel); \
  183. } \
  184. else \
  185. { \
  186. BC_SET_PIXEL(destbuf, 0) \
  187. } \
  188. BC_TO_NEXT_PIXEL(destbuf); \
  189. \
  190. if (--numbits > 0) \
  191. { \
  192. if (fgbgChar & 0x08) \
  193. { \
  194. BC_SET_PIXEL(destbuf, fgPel); \
  195. } \
  196. else \
  197. { \
  198. BC_SET_PIXEL(destbuf, 0); \
  199. } \
  200. BC_TO_NEXT_PIXEL(destbuf); \
  201. \
  202. if (--numbits > 0) \
  203. { \
  204. if (fgbgChar & 0x10) \
  205. { \
  206. BC_SET_PIXEL(destbuf, fgPel); \
  207. } \
  208. else \
  209. { \
  210. BC_SET_PIXEL(destbuf, 0); \
  211. } \
  212. BC_TO_NEXT_PIXEL(destbuf); \
  213. \
  214. if (--numbits > 0) \
  215. { \
  216. if (fgbgChar & 0x20) \
  217. { \
  218. BC_SET_PIXEL(destbuf, fgPel); \
  219. } \
  220. else \
  221. { \
  222. BC_SET_PIXEL(destbuf, 0); \
  223. } \
  224. BC_TO_NEXT_PIXEL(destbuf); \
  225. \
  226. if (--numbits > 0) \
  227. { \
  228. if (fgbgChar & 0x40) \
  229. { \
  230. BC_SET_PIXEL(destbuf, fgPel); \
  231. } \
  232. else \
  233. { \
  234. BC_SET_PIXEL(destbuf, 0); \
  235. } \
  236. BC_TO_NEXT_PIXEL(destbuf); \
  237. \
  238. if (--numbits > 0) \
  239. { \
  240. if (fgbgChar & 0x80) \
  241. { \
  242. BC_SET_PIXEL(destbuf, fgPel); \
  243. } \
  244. else \
  245. { \
  246. BC_SET_PIXEL(destbuf, 0); \
  247. } \
  248. BC_TO_NEXT_PIXEL(destbuf); \
  249. } \
  250. } \
  251. } \
  252. } \
  253. } \
  254. } \
  255. } \
  256. }
  257. /****************************************************************************/
  258. /* Decompression function begins here */
  259. /****************************************************************************/
  260. /****************************************************************************/
  261. /* */
  262. /* PBYTE pSrc */
  263. /* PBYTE pDstBuffer */
  264. /* UINT srcDataSize total bytes in image */
  265. /* UINT rowDelta scanline length in bytes */
  266. /* */
  267. /****************************************************************************/
  268. {
  269. HRESULT hr = S_OK;
  270. UINT codeLength;
  271. int pixelLength;
  272. BYTE bitMask;
  273. BYTE decode;
  274. BYTE decodeLite;
  275. BYTE decodeMega;
  276. BC_PIXEL fgPel = BC_DEFAULT_FGPEL;
  277. BC_PIXEL pixelA;
  278. BC_PIXEL pixelB;
  279. PBYTE destbuf = pDstBuffer;
  280. PBYTE endSrc = pSrc + srcDataSize;
  281. PBYTE pEndDst = destbuf + dstBufferSize;
  282. BOOL backgroundNeedsPel = FALSE;
  283. BOOL firstLine = TRUE;
  284. DC_BEGIN_FN(BC_FN_NAME);
  285. /************************************************************************/
  286. /* Loop processing the input */
  287. /************************************************************************/
  288. while (pSrc < endSrc)
  289. {
  290. /********************************************************************/
  291. /* While we are processing the first line we should keep a look out */
  292. /* for the end of the line */
  293. /********************************************************************/
  294. if (firstLine)
  295. {
  296. if ((UINT)(destbuf - pDstBuffer) >= rowDelta)
  297. {
  298. firstLine = FALSE;
  299. backgroundNeedsPel = FALSE;
  300. }
  301. }
  302. /********************************************************************/
  303. /* Get the decode */
  304. /********************************************************************/
  305. BD_CHECK_READ_ONE_BYTE(pSrc, endSrc, hr);
  306. decode = (BYTE)(*pSrc & CODE_MASK);
  307. decodeLite = (BYTE)(*pSrc & CODE_MASK_LITE);
  308. decodeMega = (BYTE)(*pSrc);
  309. /********************************************************************/
  310. /* BG RUN */
  311. /********************************************************************/
  312. if ((decode == CODE_BG_RUN) ||
  313. (decodeMega == CODE_MEGA_MEGA_BG_RUN))
  314. {
  315. if (decode == CODE_BG_RUN)
  316. {
  317. EXTRACT_LENGTH(pSrc, endSrc, codeLength, hr);
  318. }
  319. else
  320. {
  321. BD_CHECK_READ_N_BYTES(pSrc+1, endSrc, 2, hr);
  322. codeLength = DC_EXTRACT_UINT16_UA(pSrc+1);
  323. pSrc += 3;
  324. }
  325. BCTRACE((TB, "Background run %u",codeLength));
  326. if (!firstLine)
  327. {
  328. if (backgroundNeedsPel)
  329. {
  330. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, BC_PIXEL_LEN, hr);
  331. BD_CHECK_READ_N_BYTES_2ENDED(destbuf - rowDelta, pDstBuffer, pEndDst, BC_PIXEL_LEN, hr)
  332. BC_SET_PIXEL(destbuf,
  333. BC_GET_PIXEL(destbuf - rowDelta) ^ fgPel);
  334. BC_TO_NEXT_PIXEL(destbuf);
  335. codeLength--;
  336. }
  337. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, BC_PIXEL_LEN * codeLength, hr);
  338. while (codeLength-- > 0)
  339. {
  340. BD_CHECK_READ_N_BYTES_2ENDED(destbuf - rowDelta, pDstBuffer, pEndDst, BC_PIXEL_LEN, hr)
  341. BC_SET_PIXEL(destbuf, BC_GET_PIXEL(destbuf - rowDelta));
  342. BC_TO_NEXT_PIXEL(destbuf);
  343. }
  344. }
  345. else
  346. {
  347. if (backgroundNeedsPel)
  348. {
  349. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, BC_PIXEL_LEN, hr);
  350. BC_SET_PIXEL(destbuf, fgPel);
  351. BC_TO_NEXT_PIXEL(destbuf);
  352. codeLength--;
  353. }
  354. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, BC_PIXEL_LEN * codeLength, hr);
  355. while (codeLength-- > 0)
  356. {
  357. /********************************************************/
  358. /* On the first line BG colour means 0 */
  359. /********************************************************/
  360. BC_SET_PIXEL(destbuf, (BC_PIXEL)0);
  361. BC_TO_NEXT_PIXEL(destbuf);
  362. }
  363. }
  364. /****************************************************************/
  365. /* A follow on BG run will need a pel inserted */
  366. /****************************************************************/
  367. backgroundNeedsPel = TRUE;
  368. continue;
  369. }
  370. /********************************************************************/
  371. /* For any of the other runtypes a follow on BG run does not need */
  372. /* a FG pel inserted */
  373. /********************************************************************/
  374. backgroundNeedsPel = FALSE;
  375. /********************************************************************/
  376. /* FGBG IMAGE */
  377. /********************************************************************/
  378. if ((decode == CODE_FG_BG_IMAGE) ||
  379. (decodeLite == CODE_SET_FG_FG_BG) ||
  380. (decodeMega == CODE_MEGA_MEGA_FGBG) ||
  381. (decodeMega == CODE_MEGA_MEGA_SET_FGBG))
  382. {
  383. if ((decodeMega == CODE_MEGA_MEGA_FGBG) ||
  384. (decodeMega == CODE_MEGA_MEGA_SET_FGBG))
  385. {
  386. BD_CHECK_READ_N_BYTES(pSrc+1, endSrc, 2, hr);
  387. codeLength = DC_EXTRACT_UINT16_UA(pSrc+1);
  388. pSrc += 3;
  389. }
  390. else
  391. {
  392. if (decode == CODE_FG_BG_IMAGE)
  393. {
  394. EXTRACT_LENGTH_FGBG(pSrc, endSrc, codeLength, hr);
  395. }
  396. else
  397. {
  398. EXTRACT_LENGTH_FGBG_LITE(pSrc, endSrc, codeLength, hr);
  399. }
  400. }
  401. if ((decodeLite == CODE_SET_FG_FG_BG) ||
  402. (decodeMega == CODE_MEGA_MEGA_SET_FGBG))
  403. {
  404. BD_CHECK_READ_N_BYTES(pSrc, endSrc, BC_PIXEL_LEN, hr);
  405. fgPel = BC_GET_PIXEL(pSrc);
  406. BC_TO_NEXT_PIXEL(pSrc);
  407. BCTRACE((TB, "Set FGBG image %u, fgPel %06lx",
  408. codeLength, (TSUINT32)fgPel));
  409. }
  410. else
  411. {
  412. BCTRACE((TB, "FGBG image %u",codeLength));
  413. }
  414. while (codeLength > 8)
  415. {
  416. /************************************************************/
  417. /* A FGBG image is a set of bitmasks describing the */
  418. /* positions of the FG and BG colors. */
  419. /************************************************************/
  420. BD_CHECK_READ_ONE_BYTE(pSrc, endSrc, hr);
  421. bitMask = *pSrc++;
  422. if (!firstLine)
  423. {
  424. BD_CHECK_READ_N_BYTES_2ENDED(destbuf - rowDelta, pDstBuffer, pEndDst, BC_PIXEL_LEN, hr)
  425. STORE_FGBG((destbuf - rowDelta),
  426. bitMask,
  427. fgPel,
  428. 8);
  429. }
  430. else
  431. {
  432. STORE_LINE1_FGBG(bitMask, fgPel, 8);
  433. }
  434. codeLength -= 8;
  435. }
  436. if (codeLength > 0)
  437. {
  438. BD_CHECK_READ_ONE_BYTE(pSrc, endSrc, hr);
  439. bitMask = *pSrc++;
  440. if (!firstLine)
  441. {
  442. BD_CHECK_READ_N_BYTES_2ENDED(destbuf - rowDelta, pDstBuffer, pEndDst, BC_PIXEL_LEN, hr)
  443. STORE_FGBG((destbuf - rowDelta),
  444. bitMask,
  445. fgPel,
  446. codeLength);
  447. }
  448. else
  449. {
  450. STORE_LINE1_FGBG(bitMask, fgPel, codeLength);
  451. }
  452. }
  453. continue;
  454. }
  455. /********************************************************************/
  456. /* FG RUN */
  457. /********************************************************************/
  458. if ((decode == CODE_FG_RUN) ||
  459. (decodeLite == CODE_SET_FG_FG_RUN) ||
  460. (decodeMega == CODE_MEGA_MEGA_FG_RUN) ||
  461. (decodeMega == CODE_MEGA_MEGA_SET_FG_RUN))
  462. {
  463. if ((decodeMega == CODE_MEGA_MEGA_FG_RUN) ||
  464. (decodeMega == CODE_MEGA_MEGA_SET_FG_RUN))
  465. {
  466. BD_CHECK_READ_N_BYTES(pSrc+1, endSrc, 2, hr);
  467. codeLength = DC_EXTRACT_UINT16_UA(pSrc+1);
  468. pSrc += 3;
  469. }
  470. else
  471. {
  472. if (decode == CODE_FG_RUN)
  473. {
  474. EXTRACT_LENGTH(pSrc, endSrc, codeLength, hr);
  475. }
  476. else
  477. {
  478. EXTRACT_LENGTH_LITE(pSrc, endSrc, codeLength, hr);
  479. }
  480. }
  481. /****************************************************************/
  482. /* Push the old fgPel down to the ALT position */
  483. /****************************************************************/
  484. if ((decodeLite == CODE_SET_FG_FG_RUN) ||
  485. (decodeMega == CODE_MEGA_MEGA_SET_FG_RUN))
  486. {
  487. BD_CHECK_READ_N_BYTES(pSrc, endSrc, BC_PIXEL_LEN, hr);
  488. BCTRACE((TB, "Set FG run %u",codeLength));
  489. fgPel = BC_GET_PIXEL(pSrc);
  490. BC_TO_NEXT_PIXEL(pSrc);
  491. }
  492. else
  493. {
  494. BCTRACE((TB, "FG run %u",codeLength));
  495. }
  496. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, BC_PIXEL_LEN * codeLength, hr)
  497. while (codeLength-- > 0)
  498. {
  499. if (!firstLine)
  500. {
  501. BD_CHECK_READ_N_BYTES_2ENDED(destbuf - rowDelta, pDstBuffer, pEndDst, BC_PIXEL_LEN, hr)
  502. BC_SET_PIXEL(destbuf,
  503. BC_GET_PIXEL(destbuf - rowDelta) ^ fgPel);
  504. BC_TO_NEXT_PIXEL(destbuf);
  505. }
  506. else
  507. {
  508. BC_SET_PIXEL(destbuf, fgPel);
  509. BC_TO_NEXT_PIXEL(destbuf);
  510. }
  511. }
  512. continue;
  513. }
  514. /********************************************************************/
  515. /* DITHERED RUN */
  516. /********************************************************************/
  517. if ((decodeLite == CODE_DITHERED_RUN) ||
  518. (decodeMega == CODE_MEGA_MEGA_DITHER))
  519. {
  520. if (decodeMega == CODE_MEGA_MEGA_DITHER)
  521. {
  522. BD_CHECK_READ_N_BYTES(pSrc+1, endSrc, 2, hr);
  523. codeLength = DC_EXTRACT_UINT16_UA(pSrc+1);
  524. pSrc += 3;
  525. }
  526. else
  527. {
  528. EXTRACT_LENGTH_LITE(pSrc, endSrc, codeLength, hr);
  529. }
  530. BCTRACE((TB, "Dithered run %u",codeLength));
  531. BD_CHECK_READ_N_BYTES(pSrc, endSrc, BC_PIXEL_LEN * 2, hr);
  532. pixelA = BC_GET_PIXEL(pSrc);
  533. BC_TO_NEXT_PIXEL(pSrc);
  534. pixelB = BC_GET_PIXEL(pSrc);
  535. BC_TO_NEXT_PIXEL(pSrc);
  536. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, 2 * codeLength * BC_PIXEL_LEN, hr)
  537. while (codeLength-- > 0)
  538. {
  539. BC_SET_PIXEL(destbuf, pixelA);
  540. BC_TO_NEXT_PIXEL(destbuf);
  541. BC_SET_PIXEL(destbuf, pixelB);
  542. BC_TO_NEXT_PIXEL(destbuf);
  543. }
  544. continue;
  545. }
  546. /********************************************************************/
  547. /* COLOR IMAGE */
  548. /********************************************************************/
  549. if ((decode == CODE_COLOR_IMAGE) ||
  550. (decodeMega == CODE_MEGA_MEGA_CLR_IMG))
  551. {
  552. if (decodeMega == CODE_MEGA_MEGA_CLR_IMG)
  553. {
  554. BD_CHECK_READ_N_BYTES(pSrc+1, endSrc, 2, hr);
  555. codeLength = DC_EXTRACT_UINT16_UA(pSrc+1);
  556. pSrc += 3;
  557. }
  558. else
  559. {
  560. EXTRACT_LENGTH(pSrc, endSrc, codeLength, hr);
  561. }
  562. BCTRACE((TB, "Color image %u",codeLength));
  563. /****************************************************************/
  564. /* Just copy the pixel values across */
  565. /****************************************************************/
  566. pixelLength = (codeLength * BC_PIXEL_LEN);
  567. BD_CHECK_READ_N_BYTES(pSrc, endSrc, pixelLength, hr);
  568. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, pixelLength, hr);
  569. while (pixelLength-- > 0)
  570. {
  571. *destbuf++ = *pSrc++;
  572. }
  573. continue;
  574. }
  575. /********************************************************************/
  576. /* COLOR RUN */
  577. /********************************************************************/
  578. if ((decode == CODE_COLOR_RUN) ||
  579. (decodeMega == CODE_MEGA_MEGA_COLOR_RUN))
  580. {
  581. if (decodeMega == CODE_MEGA_MEGA_COLOR_RUN)
  582. {
  583. BD_CHECK_READ_N_BYTES(pSrc+1, endSrc, 2, hr);
  584. codeLength = DC_EXTRACT_UINT16_UA(pSrc+1);
  585. pSrc += 3;
  586. }
  587. else
  588. {
  589. EXTRACT_LENGTH(pSrc, endSrc, codeLength, hr);
  590. }
  591. BCTRACE((TB, "Color run %u",codeLength));
  592. BD_CHECK_READ_N_BYTES(pSrc, endSrc, BC_PIXEL_LEN, hr);
  593. pixelA = BC_GET_PIXEL(pSrc);
  594. BC_TO_NEXT_PIXEL(pSrc);
  595. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, codeLength * BC_PIXEL_LEN, hr)
  596. while (codeLength-- > 0)
  597. {
  598. BC_SET_PIXEL(destbuf, pixelA);
  599. BC_TO_NEXT_PIXEL(destbuf);
  600. }
  601. continue;
  602. }
  603. /********************************************************************/
  604. /* If we get here then the code must be a special one */
  605. /********************************************************************/
  606. BCTRACE((TB, "Special code %x",decodeMega));
  607. switch (decodeMega)
  608. {
  609. case CODE_BLACK:
  610. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, BC_PIXEL_LEN, hr)
  611. BC_SET_PIXEL(destbuf, (BC_PIXEL)0);
  612. BC_TO_NEXT_PIXEL(destbuf);
  613. break;
  614. case CODE_WHITE:
  615. BD_CHECK_WRITE_N_BYTES(destbuf, pEndDst, BC_PIXEL_LEN, hr)
  616. BC_SET_PIXEL(destbuf, BC_DEFAULT_FGPEL);
  617. BC_TO_NEXT_PIXEL(destbuf);
  618. break;
  619. /****************************************************************/
  620. /* Ignore the unreachable code warnings that follow */
  621. /* Simply because we use the STORE_FGBG macro with a constant */
  622. /* value */
  623. /****************************************************************/
  624. case CODE_SPECIAL_FGBG_1:
  625. if (!firstLine)
  626. {
  627. BD_CHECK_READ_N_BYTES_2ENDED(destbuf - rowDelta, pDstBuffer, pEndDst, BC_PIXEL_LEN, hr)
  628. STORE_FGBG((destbuf - rowDelta),
  629. SPECIAL_FGBG_CODE_1,
  630. fgPel,
  631. 8);
  632. }
  633. else
  634. {
  635. STORE_LINE1_FGBG(SPECIAL_FGBG_CODE_1, fgPel, 8);
  636. }
  637. break;
  638. case CODE_SPECIAL_FGBG_2:
  639. if (!firstLine)
  640. {
  641. BD_CHECK_READ_N_BYTES_2ENDED(destbuf - rowDelta, pDstBuffer, pEndDst, BC_PIXEL_LEN, hr)
  642. STORE_FGBG((destbuf - rowDelta),
  643. SPECIAL_FGBG_CODE_2,
  644. fgPel,
  645. 8);
  646. }
  647. else
  648. {
  649. STORE_LINE1_FGBG(SPECIAL_FGBG_CODE_2, fgPel, 8);
  650. }
  651. break;
  652. default:
  653. {
  654. BCTRACE((TB, "Invalid compression data %x",decodeMega));
  655. }
  656. break;
  657. }
  658. pSrc++;
  659. }
  660. BCTRACE((TB, "Decompressed to %u bytes", destbuf - pDstBuffer));
  661. DC_EXIT_POINT:
  662. DC_END_FN();
  663. return hr;
  664. }