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.

661 lines
19 KiB

  1. // File: Blt.cpp
  2. // Author: Michael Marr (mikemarr)
  3. //
  4. // History:
  5. // -@- 09/23/97 (mikemarr) copied to DXCConv from d2d\mmimage
  6. // -@- 10/28/97 (mikemarr) added colorfill routines
  7. //
  8. // Notes:
  9. // Asserts can not be used because the code may be executing on
  10. // pixels in the front buffer. If there is an assertion failure,
  11. // GDI might lock up.
  12. #include "stdafx.h"
  13. #include "PalMap.h"
  14. #include "Blt.h"
  15. ColorFillFn g_rgColorFillFn[5] = {
  16. NULL, ColorFill8, ColorFill16, ColorFill24, ColorFill32
  17. };
  18. HasPixelFn g_rgHasPixelFn[5] = {
  19. NULL, HasPixel8, HasPixel16, HasPixel24, HasPixel32
  20. };
  21. // Function: ColorFill
  22. // These functions are designed for small color fills...
  23. HRESULT
  24. ColorFill8(BYTE *pDstPixels, DWORD nDstPitch,
  25. DWORD nWidth, DWORD nHeight, DWORD dwColor)
  26. {
  27. BYTE iColor = (BYTE) dwColor;
  28. DWORD i, j;
  29. for (i = 0; i < nHeight; i++) {
  30. for (j = 0; j < nWidth; j++)
  31. pDstPixels[j] = iColor;
  32. pDstPixels += nDstPitch;
  33. }
  34. return S_OK;
  35. }
  36. HRESULT
  37. ColorFill16(BYTE *pDstPixels, DWORD nDstPitch,
  38. DWORD nWidth, DWORD nHeight, DWORD dwColor)
  39. {
  40. WORD wColor = (WORD) dwColor;
  41. DWORD i, j;
  42. for (i = 0; i < nHeight; i++) {
  43. WORD *pwDstPixels = (WORD *) pDstPixels;
  44. for (j = 0; j < nWidth; j++)
  45. *pwDstPixels++ = wColor;
  46. pDstPixels += nDstPitch;
  47. }
  48. return S_OK;
  49. }
  50. HRESULT
  51. ColorFill24(BYTE *pDstPixels, DWORD nDstPitch,
  52. DWORD nWidth, DWORD nHeight, DWORD dwColor)
  53. {
  54. BYTE c0 = (BYTE) dwColor;
  55. BYTE c1 = (BYTE) (dwColor >> 8);
  56. BYTE c2 = (BYTE) (dwColor >> 16);
  57. DWORD i, j;
  58. for (i = 0; i < nHeight; i++) {
  59. BYTE *pDstNext = pDstPixels + nDstPitch;
  60. for (j = 0; j < nWidth; j++) {
  61. pDstPixels[0] = c0;
  62. pDstPixels[1] = c1;
  63. pDstPixels[2] = c2;
  64. pDstPixels += 3;
  65. }
  66. pDstPixels = pDstNext;
  67. }
  68. return S_OK;
  69. }
  70. HRESULT
  71. ColorFill32(BYTE *pDstPixels, DWORD nDstPitch,
  72. DWORD nWidth, DWORD nHeight, DWORD dwColor)
  73. {
  74. DWORD i, j;
  75. for (i = 0; i < nHeight; i++) {
  76. DWORD *pdwDstPixels = (DWORD *) pDstPixels;
  77. for (j = 0; j < nWidth; j++)
  78. *pdwDstPixels++ = dwColor;
  79. pDstPixels += nDstPitch;
  80. }
  81. return S_OK;
  82. }
  83. HRESULT
  84. HasPixel8(const BYTE *pSrcPixels, DWORD nSrcPitch, DWORD dwPixel,
  85. DWORD nSrcWidth, DWORD nHeight, BOOL *pb)
  86. {
  87. BYTE iPixel = (BYTE) dwPixel;
  88. if (nSrcPitch == nSrcWidth) {
  89. // do a flat search thru contiguous memory
  90. *pb = (memchr(pSrcPixels, iPixel, nSrcPitch * nHeight) != NULL);
  91. } else {
  92. // do search line by line
  93. for (; nHeight; nHeight--) {
  94. if (memchr(pSrcPixels, iPixel, nSrcWidth) != NULL) {
  95. *pb = TRUE;
  96. return S_OK;
  97. }
  98. pSrcPixels += nSrcPitch;
  99. }
  100. *pb = FALSE;
  101. }
  102. return S_OK;
  103. }
  104. HRESULT
  105. HasPixel16(const BYTE *pSrcPixels, DWORD nSrcPitch, DWORD dwPixel,
  106. DWORD nSrcWidth, DWORD nHeight, BOOL *pb)
  107. {
  108. WORD wPixel = (WORD) dwPixel;
  109. for (; nHeight; nHeight--) {
  110. const WORD *pPixels = (const WORD *) pSrcPixels;
  111. const WORD *pLimit = pPixels + nSrcWidth;
  112. while (pPixels != pLimit) {
  113. if (*pPixels++ == wPixel) {
  114. *pb = TRUE;
  115. return S_OK;
  116. }
  117. }
  118. pSrcPixels += nSrcPitch;
  119. }
  120. *pb = FALSE;
  121. return S_OK;
  122. }
  123. HRESULT
  124. HasPixel24(const BYTE *pSrcPixels, DWORD nSrcPitch, DWORD dwPixel,
  125. DWORD nSrcWidth, DWORD nHeight, BOOL *pb)
  126. {
  127. // REVIEW: only works on little endian machines
  128. BYTE c0 = (BYTE) dwPixel;
  129. BYTE c1 = (BYTE) (dwPixel >> 8);
  130. BYTE c2 = (BYTE) (dwPixel >> 16);
  131. DWORD nWidth = nSrcWidth * 3;
  132. for (; nHeight; nHeight--) {
  133. const BYTE *pPixels = pSrcPixels;
  134. const BYTE *pLimit = pPixels + nWidth;
  135. while (pPixels != pLimit) {
  136. if ((pPixels[0] == c0) && (pPixels[1] == c1) && (pPixels[2] == c2)) {
  137. *pb = TRUE;
  138. return S_OK;
  139. }
  140. pPixels += 3;
  141. }
  142. pSrcPixels += nSrcPitch;
  143. }
  144. *pb = FALSE;
  145. return S_OK;
  146. }
  147. HRESULT
  148. HasPixel32(const BYTE *pSrcPixels, DWORD nSrcPitch, DWORD dwPixel,
  149. DWORD nSrcWidth, DWORD nHeight, BOOL *pb)
  150. {
  151. for (; nHeight; nHeight--) {
  152. const DWORD *pPixels = (const DWORD *) pSrcPixels;
  153. const DWORD *pLimit = pPixels + nSrcWidth;
  154. while (pPixels != pLimit) {
  155. if (*pPixels++ == dwPixel) {
  156. *pb = TRUE;
  157. return S_OK;
  158. }
  159. }
  160. pSrcPixels += nSrcPitch;
  161. }
  162. *pb = FALSE;
  163. return S_OK;
  164. }
  165. HRESULT
  166. BltFast(const BYTE *pSrcPixels, DWORD nSrcPitch,
  167. BYTE *pDstPixels, DWORD nDstPitch, DWORD nSrcWidth, DWORD nHeight)
  168. {
  169. if (nSrcWidth == nDstPitch) {
  170. // do a flat copy
  171. memcpy(pDstPixels, pSrcPixels, nSrcPitch * nHeight);
  172. } else {
  173. LPBYTE pPixelLimit = pDstPixels + nDstPitch * nHeight;
  174. // copy each row
  175. for (; pDstPixels != pPixelLimit; ) {
  176. memcpy(pDstPixels, pSrcPixels, nSrcWidth);
  177. pDstPixels += nDstPitch;
  178. pSrcPixels += nSrcPitch;
  179. }
  180. }
  181. return S_OK;
  182. }
  183. HRESULT
  184. BltFast8CK(const BYTE *pSrcPixels, DWORD nSrcPitch,
  185. BYTE *pDstPixels, DWORD nDstPitch,
  186. DWORD nSrcWidth, DWORD nHeight, DWORD dwTrans)
  187. {
  188. if ((nSrcWidth == 0) || (nHeight == 0))
  189. return S_OK;
  190. DWORD nRemainder = (nSrcWidth & 0x7);
  191. DWORD nAligned = (nSrcWidth & ~0x7);
  192. const BYTE *pSrcLineStart = pSrcPixels;
  193. const BYTE *pPixelLimit = pSrcPixels + (nHeight * nSrcPitch);
  194. DWORD nSrcAlignedPitch = nSrcPitch + nAligned;
  195. DWORD nDstAlignedPitch = nDstPitch + nAligned;
  196. pSrcPixels += nAligned;
  197. pDstPixels += nAligned;
  198. BYTE iTrans = BYTE(dwTrans), uch;
  199. do {
  200. switch (nRemainder) {
  201. do {
  202. case 0: pDstPixels -= 8; pSrcPixels -= 8;
  203. if ((uch = pSrcPixels[7]) != iTrans) pDstPixels[7] = uch;
  204. case 7: if ((uch = pSrcPixels[6]) != iTrans) pDstPixels[6] = uch;
  205. case 6: if ((uch = pSrcPixels[5]) != iTrans) pDstPixels[5] = uch;
  206. case 5: if ((uch = pSrcPixels[4]) != iTrans) pDstPixels[4] = uch;
  207. case 4: if ((uch = pSrcPixels[3]) != iTrans) pDstPixels[3] = uch;
  208. case 3: if ((uch = pSrcPixels[2]) != iTrans) pDstPixels[2] = uch;
  209. case 2: if ((uch = pSrcPixels[1]) != iTrans) pDstPixels[1] = uch;
  210. case 1: if ((uch = pSrcPixels[0]) != iTrans) pDstPixels[0] = uch;
  211. } while (pSrcPixels != pSrcLineStart);
  212. }
  213. pSrcLineStart += nSrcPitch;
  214. pSrcPixels += nSrcAlignedPitch;
  215. pDstPixels += nDstAlignedPitch;
  216. } while (pSrcLineStart != pPixelLimit);
  217. return S_OK;
  218. }
  219. HRESULT
  220. BltFastMirrorY(const BYTE *pSrcPixels, DWORD nSrcPitch,
  221. BYTE *pDstPixels, DWORD nDstPitch, DWORD nSrcWidth, DWORD nHeight)
  222. {
  223. LPBYTE pPixelLimit = pDstPixels + nDstPitch * nHeight;
  224. // set the src pixels to point to the last line of the bitmap
  225. pSrcPixels += nSrcPitch * (nHeight - 1);
  226. // copy each row
  227. for (; pDstPixels != pPixelLimit; ) {
  228. memcpy(pDstPixels, pSrcPixels, nSrcWidth);
  229. pDstPixels += nDstPitch;
  230. pSrcPixels -= nSrcPitch;
  231. }
  232. return S_OK;
  233. }
  234. HRESULT
  235. BltFastRGBToRGB(const BYTE *pSrcPixels, DWORD nSrcPitch,
  236. BYTE *pDstPixels, DWORD nDstPitch,
  237. DWORD nWidth, DWORD nHeight,
  238. const CPixelInfo &pixiSrc, const CPixelInfo &pixiDst)
  239. {
  240. if (pixiSrc.nBPP == 24) {
  241. if (pixiDst.nBPP == 16)
  242. return BltFast24To16(pSrcPixels, nSrcPitch, pDstPixels, nDstPitch,
  243. nWidth, nHeight, pixiSrc, pixiDst);
  244. if (pixiDst.nBPP == 32)
  245. return BltFast24To32(pSrcPixels, nSrcPitch, pDstPixels, nDstPitch,
  246. nWidth, nHeight, pixiSrc, pixiDst);
  247. } else if (pixiSrc.nBPP == 32) {
  248. if (pixiDst.nBPP == 32)
  249. return BltFast32To32(pSrcPixels, nSrcPitch, pDstPixels, nDstPitch,
  250. nWidth, nHeight, pixiSrc, pixiDst);
  251. }
  252. return E_NOTIMPL;
  253. }
  254. HRESULT
  255. BltFast32To32(const BYTE *pSrcPixels, DWORD nSrcPitch,
  256. BYTE *pDstPixels, DWORD nDstPitch,
  257. DWORD nWidth, DWORD nHeight,
  258. const CPixelInfo &pixiSrc, const CPixelInfo &pixiDst)
  259. {
  260. if (nSrcPitch == 0)
  261. nSrcPitch = nWidth * 4;
  262. if (nDstPitch == 0)
  263. nDstPitch = nWidth * 4;
  264. DWORD nDeltaSrcPitch = nSrcPitch - (nWidth * 4);
  265. const BYTE *pPixelLimit = pSrcPixels + nSrcPitch * nHeight;
  266. DWORD iRed = pixiSrc.iRed, iBlue = pixiSrc.iBlue;
  267. // copy each row
  268. for (; pSrcPixels != pPixelLimit; ) {
  269. LPDWORD pdwDstPixel = (LPDWORD) pDstPixels;
  270. for (DWORD i = nWidth; i != 0; i--) {
  271. *pdwDstPixel++ = pixiDst.Pack(pSrcPixels[iRed], pSrcPixels[1], pSrcPixels[iBlue], pSrcPixels[3]);
  272. pSrcPixels += 4;
  273. }
  274. pDstPixels += nDstPitch;
  275. pSrcPixels += nDeltaSrcPitch;
  276. }
  277. return S_OK;
  278. }
  279. HRESULT
  280. BltFast24To16(const BYTE *pSrcPixels, DWORD nSrcPitch,
  281. BYTE *pDstPixels, DWORD nDstPitch,
  282. DWORD nWidth, DWORD nHeight,
  283. const CPixelInfo &pixiSrc, const CPixelInfo &pixiDst)
  284. {
  285. if (nSrcPitch == 0)
  286. nSrcPitch = nWidth * 3;
  287. if (nDstPitch == 0)
  288. nDstPitch = nWidth * 2;
  289. DWORD nDeltaSrcPitch = nSrcPitch - (nWidth * 3);
  290. const BYTE *pPixelLimit = pSrcPixels + nSrcPitch * nHeight;
  291. DWORD iRed = pixiSrc.iRed, iBlue = pixiSrc.iBlue;
  292. // copy each row
  293. for (; pSrcPixels != pPixelLimit; ) {
  294. LPWORD pwDstPixel = (LPWORD) pDstPixels;
  295. for (DWORD i = nWidth; i != 0; i--) {
  296. *pwDstPixel++ = pixiDst.Pack16(pSrcPixels[iRed], pSrcPixels[1], pSrcPixels[iBlue]);
  297. pSrcPixels += 3;
  298. }
  299. pDstPixels += nDstPitch;
  300. pSrcPixels += nDeltaSrcPitch;
  301. }
  302. return S_OK;
  303. }
  304. HRESULT
  305. BltFast24To32(const BYTE *pSrcPixels, DWORD nSrcPitch,
  306. BYTE *pDstPixels, DWORD nDstPitch,
  307. DWORD nWidth, DWORD nHeight,
  308. const CPixelInfo &pixiSrc, const CPixelInfo &pixiDst)
  309. {
  310. if (nSrcPitch == 0)
  311. nSrcPitch = nWidth * 3;
  312. if (nDstPitch == 0)
  313. nDstPitch = nWidth * 4;
  314. DWORD nDeltaSrcPitch = nSrcPitch - (nWidth * 3);
  315. DWORD iRed = pixiSrc.iRed, iBlue = pixiSrc.iBlue;
  316. // copy each row
  317. const BYTE *pPixelLimit = pSrcPixels + nSrcPitch * nHeight;
  318. for (; pSrcPixels != pPixelLimit; ) {
  319. LPDWORD pdwDstPixel = (LPDWORD) pDstPixels;
  320. for (DWORD i = nWidth; i != 0; i--) {
  321. *pdwDstPixel++ = pixiDst.Pack(pSrcPixels[iRed], pSrcPixels[1], pSrcPixels[iBlue]);
  322. pSrcPixels += 3;
  323. }
  324. pDstPixels += nDstPitch;
  325. pSrcPixels += nDeltaSrcPitch;
  326. }
  327. return S_OK;
  328. }
  329. HRESULT
  330. BltFast8To4(const BYTE *pSrcPixels, DWORD nSrcPitch,
  331. BYTE *pDstPixels, DWORD nDstPitch,
  332. DWORD nWidth, DWORD nHeight, DWORD nOffset)
  333. {
  334. return E_NOTIMPL;
  335. }
  336. HRESULT
  337. BltFast8To2(const BYTE *pSrcPixels, DWORD nSrcPitch,
  338. BYTE *pDstPixels, DWORD nDstPitch,
  339. DWORD nWidth, DWORD nHeight, DWORD nOffset)
  340. {
  341. return E_NOTIMPL;
  342. }
  343. HRESULT
  344. BltFast8To1(const BYTE *pSrcPixels, long nSrcPitch,
  345. BYTE *pDstPixels, long nDstPitch,
  346. DWORD nWidth, DWORD nHeight, DWORD nOffset)
  347. {
  348. HRESULT hr = E_NOTIMPL;
  349. return hr;
  350. }
  351. HRESULT
  352. BltFast8To8T(const BYTE *pSrcPixel, long nSrcPitch, BYTE *pDstPixel, long nDstPitch,
  353. DWORD nWidth, DWORD nHeight, const BYTE *pIndexMap)
  354. {
  355. if ((nWidth == 0) || (nHeight == 0))
  356. return S_OK;
  357. DWORD nRemainder = (nWidth & 0x7);
  358. DWORD nAligned = (nWidth & ~0x7);
  359. const BYTE *pSrcLineStart = pSrcPixel;
  360. const BYTE *pPixelLimit = pSrcPixel + (nHeight * nSrcPitch);
  361. DWORD nSrcAlignedPitch = nSrcPitch + nAligned;
  362. DWORD nDstAlignedPitch = nDstPitch + nAligned;
  363. pSrcPixel += nAligned;
  364. pDstPixel += nAligned;
  365. do {
  366. switch (nRemainder) {
  367. do {
  368. case 0: pDstPixel -= 8; pSrcPixel -= 8;
  369. pDstPixel[7] = pIndexMap[pSrcPixel[7]];
  370. case 7: pDstPixel[6] = pIndexMap[pSrcPixel[6]];
  371. case 6: pDstPixel[5] = pIndexMap[pSrcPixel[5]];
  372. case 5: pDstPixel[4] = pIndexMap[pSrcPixel[4]];
  373. case 4: pDstPixel[3] = pIndexMap[pSrcPixel[3]];
  374. case 3: pDstPixel[2] = pIndexMap[pSrcPixel[2]];
  375. case 2: pDstPixel[1] = pIndexMap[pSrcPixel[1]];
  376. case 1: pDstPixel[0] = pIndexMap[pSrcPixel[0]];
  377. } while (pSrcPixel != pSrcLineStart);
  378. }
  379. pSrcLineStart += nSrcPitch;
  380. pSrcPixel += nSrcAlignedPitch;
  381. pDstPixel += nDstAlignedPitch;
  382. } while (pSrcLineStart != pPixelLimit);
  383. return S_OK;
  384. }
  385. HRESULT
  386. BltFast8To16T(const BYTE *pSrcPixel, long nSrcPitch, BYTE *pDstPixel, long nDstPitch,
  387. DWORD nWidth, DWORD nHeight, const BYTE *pIndexMap)
  388. {
  389. #ifdef _DEBUG
  390. if ((long(pDstPixel) & 0x1) || (nDstPitch & 0x1) || (nWidth == 0) || (nHeight == 0))
  391. return E_INVALIDARG;
  392. #endif
  393. DWORD nRemainder = (nWidth & 0x7);
  394. DWORD nAligned = (nWidth & ~0x7);
  395. const BYTE *pSrcLineStart = pSrcPixel;
  396. const BYTE *pPixelLimit = pSrcPixel + (nHeight * nSrcPitch);
  397. DWORD nSrcAlignedPitch = nSrcPitch + nAligned;
  398. DWORD nDstAlignedPitch = (nDstPitch >> 1) + nAligned;
  399. pSrcPixel += nAligned;
  400. WORD *pDstPixel16 = ((WORD *) pDstPixel) + nAligned;
  401. MapEntry16 *pIndexMap16 = (MapEntry16 *) pIndexMap;
  402. do {
  403. switch (nRemainder) {
  404. do {
  405. case 0: pDstPixel16 -= 8; pSrcPixel -= 8;
  406. pDstPixel16[7] = pIndexMap16[pSrcPixel[7]];
  407. case 7: pDstPixel16[6] = pIndexMap16[pSrcPixel[6]];
  408. case 6: pDstPixel16[5] = pIndexMap16[pSrcPixel[5]];
  409. case 5: pDstPixel16[4] = pIndexMap16[pSrcPixel[4]];
  410. case 4: pDstPixel16[3] = pIndexMap16[pSrcPixel[3]];
  411. case 3: pDstPixel16[2] = pIndexMap16[pSrcPixel[2]];
  412. case 2: pDstPixel16[1] = pIndexMap16[pSrcPixel[1]];
  413. case 1: pDstPixel16[0] = pIndexMap16[pSrcPixel[0]];
  414. } while (pSrcPixel != pSrcLineStart);
  415. }
  416. pSrcLineStart += nSrcPitch;
  417. pSrcPixel += nSrcAlignedPitch;
  418. pDstPixel16 += nDstAlignedPitch;
  419. } while (pSrcLineStart != pPixelLimit);
  420. return S_OK;
  421. }
  422. HRESULT
  423. BltFast8To24T(const BYTE *pSrcPixels, long nSrcPitch, BYTE *pDstPixels, long nDstPitch,
  424. DWORD nWidth, DWORD nHeight, const BYTE *pIndexMap)
  425. {
  426. MapEntry24 *pIndexMap24 = (MapEntry24 *) pIndexMap;
  427. BYTE *pDstPixelsLimit = pDstPixels + nDstPitch * nHeight;
  428. int nDstWidth = nWidth * 3;
  429. for (; pDstPixels != pDstPixelsLimit; ) {
  430. const BYTE *pSrcPixel = pSrcPixels;
  431. BYTE *pDstPixel = pDstPixels;
  432. BYTE *pDstPixelLimit = pDstPixel + nDstWidth;
  433. for (; pDstPixel != pDstPixelLimit; ) {
  434. MapEntry24 mePixel = pIndexMap24[*pSrcPixel++];
  435. *pDstPixel++ = (BYTE) (mePixel);
  436. *pDstPixel++ = (BYTE) (mePixel >> 8);
  437. *pDstPixel++ = (BYTE) (mePixel >> 16);
  438. }
  439. pDstPixels += nDstPitch;
  440. pSrcPixels += nSrcPitch;
  441. }
  442. return S_OK;
  443. }
  444. HRESULT
  445. BltFast8To32T(const BYTE *pSrcPixels, long nSrcPitch, BYTE *pDstPixels, long nDstPitch,
  446. DWORD nWidth, DWORD nHeight, const BYTE *pIndexMap)
  447. {
  448. #ifdef _DEBUG
  449. if ((long(pDstPixels) & 0x3) != 0)
  450. return E_INVALIDARG;
  451. #endif
  452. MapEntry32 *pIndexMap32 = (MapEntry32 *) pIndexMap;
  453. int nDstPitch32 = nDstPitch >> 2;
  454. DWORD *pDstPixels32 = (DWORD *) pDstPixels;
  455. DWORD *pDstPixelsLimit = pDstPixels32 + nDstPitch32 * nHeight;
  456. for (; pDstPixels32 != pDstPixelsLimit; ) {
  457. const BYTE *pSrcPixel = pSrcPixels;
  458. DWORD *pDstPixel = pDstPixels32;
  459. DWORD *pDstPixelLimit = pDstPixel + nWidth;
  460. for (; pDstPixel != pDstPixelLimit; ) {
  461. *pDstPixel++ = pIndexMap32[*pSrcPixel++];
  462. }
  463. pDstPixels32 += nDstPitch32;
  464. pSrcPixels += nSrcPitch;
  465. }
  466. return S_OK;
  467. }
  468. //
  469. // RLE
  470. //
  471. HRESULT
  472. BltFastRLE8(DWORD nXPos, DWORD nYPos, const BYTE *pSrcPixels, long nSrcPitch,
  473. BYTE *pDstPixels, long nDstPitch, const LPRECT prSrcRect)
  474. {
  475. return E_NOTIMPL;
  476. }
  477. HRESULT
  478. BltFastRLE8To8T(DWORD nXPos, DWORD nYPos, const BYTE *pSrcPixels, long nSrcPitch,
  479. BYTE *pDstPixels, long nDstPitch, const LPRECT prSrcRect,
  480. const BYTE *pIndexMap)
  481. {
  482. return E_NOTIMPL;
  483. }
  484. HRESULT
  485. BltFastRLE8To16T(DWORD nXPos, DWORD nYPos, const BYTE *pSrcPixels, long nSrcPitch,
  486. BYTE *pDstPixels, long nDstPitch, const LPRECT prSrcRect,
  487. const BYTE *pIndexMap)
  488. {
  489. return E_NOTIMPL;
  490. }
  491. HRESULT
  492. BltFastRLE8To24T(DWORD nXPos, DWORD nYPos, const BYTE *pSrcPixels, long nSrcPitch,
  493. BYTE *pDstPixels, long nDstPitch, const LPRECT prSrcRect,
  494. const BYTE *pIndexMap)
  495. {
  496. return E_NOTIMPL;
  497. }
  498. HRESULT
  499. BltFastRLE8To32T(DWORD nXPos, DWORD nYPos, const BYTE *pSrcPixels, long nSrcPitch,
  500. BYTE *pDstPixels, long nDstPitch, const LPRECT prSrcRect,
  501. const BYTE *pIndexMap)
  502. {
  503. return E_NOTIMPL;
  504. }
  505. /*
  506. // Function: Write4BitRow
  507. // This function packs a buffer of unsigned char's representing
  508. // 4 bit numbers into a packed unsigned char buffer. It is assumed
  509. // that the bytes in the src have the uppermost 4 bits zeroed out.
  510. void *
  511. Write4BitRow(void *pDst, const void *pSrc, unsigned int cCount)
  512. {
  513. // use an inverse Duff machine
  514. int nRemainder = cCount & 0x07;
  515. int nAligned = cCount - nRemainder;
  516. const unsigned char *puchSrc = (const unsigned char *) pSrc + nAligned;
  517. unsigned char *puchDst = (unsigned char *) pDst + (nAligned >> 1);
  518. unsigned char uchCompositionBuf = 0;
  519. switch (nRemainder) {
  520. do {
  521. puchDst -= 4; puchSrc -= 8;
  522. uchCompositionBuf = puchSrc[7];
  523. case 7: puchDst[3] = (puchSrc[6] << 4) | uchCompositionBuf;
  524. case 6: uchCompositionBuf = puchSrc[5];
  525. case 5: puchDst[2] = (puchSrc[4] << 4) | uchCompositionBuf;
  526. case 4: uchCompositionBuf = puchSrc[3];
  527. case 3: puchDst[1] = (puchSrc[2] << 4) | uchCompositionBuf;
  528. case 2: uchCompositionBuf = puchSrc[1];
  529. case 1: puchDst[0] = (puchSrc[0] << 4) | uchCompositionBuf;
  530. case 0: ;
  531. } while (puchDst != (unsigned char *) pDst);
  532. }
  533. return pDst;
  534. }
  535. // Function: Write2BitRow
  536. // This function packs a buffer of unsigned char's representing
  537. // 2 bit numbers into a packed unsigned char buffer. It is assumed
  538. // that the bytes in the src have the uppermost 6 bits zeroed out.
  539. void *
  540. Write2BitRow(void *pDst, const void *pSrc, unsigned int cCount)
  541. {
  542. // use an inverse Duff machine
  543. int nRemainder = cCount & 0x07;
  544. int nAligned = cCount - nRemainder;
  545. const unsigned char *puchSrc = (const unsigned char *) pSrc + nAligned;
  546. unsigned char *puchDst = (unsigned char *) pDst + (nAligned >> 2);
  547. unsigned char uchCompositionBuf = 0;
  548. switch (nRemainder) {
  549. do {
  550. puchDst -= 2; puchSrc -= 8;
  551. uchCompositionBuf = puchSrc[7];
  552. case 7: uchCompositionBuf |= (puchSrc[6] << 2);
  553. case 6: uchCompositionBuf |= (puchSrc[5] << 4);
  554. case 5: puchDst[1] = (puchSrc[4] << 6) | uchCompositionBuf;
  555. case 4: uchCompositionBuf = puchSrc[3];
  556. case 3: uchCompositionBuf |= (puchSrc[2] << 2);
  557. case 2: uchCompositionBuf |= (puchSrc[1] << 4);
  558. case 1: puchDst[0] = (puchSrc[0] << 6) | uchCompositionBuf;
  559. case 0: ;
  560. } while (puchDst != (unsigned char *) pDst);
  561. }
  562. return pDst;
  563. }
  564. // Function: Write1BitRow
  565. // This function packs a buffer of unsigned char's representing
  566. // 1 bit numbers into a packed unsigned char buffer. It is assumed
  567. // that the bytes in the src have the uppermost 7 bits zeroed out.
  568. void *
  569. Write1BitRow(void *pDst, const void *pSrc, unsigned int cCount)
  570. {
  571. // use an inverse Duff machine
  572. int nRemainder = cCount & 0x07;
  573. int nAligned = cCount - nRemainder;
  574. const unsigned char *puchSrc = (const unsigned char *) pSrc + nAligned;
  575. unsigned char *puchDst = (unsigned char *) pDst + (nAligned >> 3);
  576. unsigned char uchCompositionBuf = 0;
  577. switch (nRemainder) {
  578. do {
  579. puchDst -= 1; puchSrc -= 8;
  580. uchCompositionBuf = puchSrc[7];
  581. case 7: uchCompositionBuf |= (puchSrc[6] << 1);
  582. case 6: uchCompositionBuf |= (puchSrc[5] << 2);
  583. case 5: uchCompositionBuf |= (puchSrc[4] << 3);
  584. case 4: uchCompositionBuf |= (puchSrc[3] << 4);
  585. case 3: uchCompositionBuf |= (puchSrc[2] << 5);
  586. case 2: uchCompositionBuf |= (puchSrc[1] << 6);
  587. case 1: puchDst[0] = (puchSrc[0] << 7) | uchCompositionBuf;
  588. case 0: ;
  589. } while (puchDst != (unsigned char *) pDst);
  590. }
  591. return pDst;
  592. }
  593. */