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.

822 lines
19 KiB

  1. #include "stdafx.h"
  2. #include "pngfilt.h"
  3. #include "resource.h"
  4. #include "cpngfilt.h"
  5. #include "scanline.h"
  6. void DuplicateScanLineARGB32( void* pScanLine, ULONG nDeltaX, ULONG nFullPixels,
  7. ULONG nFullPixelWidth, ULONG nPartialPixelWidth )
  8. {
  9. BYTE* pbSrcPixel;
  10. BYTE* pbDestPixel;
  11. ULONG iSrcPixel;
  12. ULONG iDestPixel;
  13. BYTE bAlpha;
  14. BYTE bRed;
  15. BYTE bGreen;
  16. BYTE bBlue;
  17. pbSrcPixel = LPBYTE( pScanLine );
  18. for( iSrcPixel = 0; iSrcPixel < nFullPixels; iSrcPixel++ )
  19. {
  20. bAlpha = pbSrcPixel[4];
  21. bRed = pbSrcPixel[2];
  22. bGreen = pbSrcPixel[1];
  23. bBlue = pbSrcPixel[0];
  24. pbDestPixel = pbSrcPixel+4;
  25. for( iDestPixel = 1; iDestPixel < nFullPixelWidth; iDestPixel++ )
  26. {
  27. pbDestPixel[0] = bBlue;
  28. pbDestPixel[1] = bGreen;
  29. pbDestPixel[2] = bRed;
  30. pbDestPixel[3] = bAlpha;
  31. pbDestPixel += 4;
  32. }
  33. pbSrcPixel += 4*nDeltaX;
  34. }
  35. if( nPartialPixelWidth > 0 )
  36. {
  37. bAlpha = pbSrcPixel[3];
  38. bRed = pbSrcPixel[2];
  39. bGreen = pbSrcPixel[1];
  40. bBlue = pbSrcPixel[0];
  41. pbDestPixel = pbSrcPixel+4;
  42. for( iDestPixel = 1; iDestPixel < nPartialPixelWidth; iDestPixel++ )
  43. {
  44. pbDestPixel[0] = bBlue;
  45. pbDestPixel[1] = bGreen;
  46. pbDestPixel[2] = bRed;
  47. pbDestPixel[3] = bAlpha;
  48. pbDestPixel += 4;
  49. }
  50. }
  51. }
  52. void DuplicateScanLineBGR24( void* pScanLine, ULONG nDeltaX, ULONG nFullPixels,
  53. ULONG nFullPixelWidth, ULONG nPartialPixelWidth )
  54. {
  55. BYTE* pbSrcPixel;
  56. BYTE* pbDestPixel;
  57. ULONG iSrcPixel;
  58. ULONG iDestPixel;
  59. BYTE bRed;
  60. BYTE bGreen;
  61. BYTE bBlue;
  62. pbSrcPixel = LPBYTE( pScanLine );
  63. for( iSrcPixel = 0; iSrcPixel < nFullPixels; iSrcPixel++ )
  64. {
  65. bRed = pbSrcPixel[2];
  66. bGreen = pbSrcPixel[1];
  67. bBlue = pbSrcPixel[0];
  68. pbDestPixel = pbSrcPixel+3;
  69. for( iDestPixel = 1; iDestPixel < nFullPixelWidth; iDestPixel++ )
  70. {
  71. pbDestPixel[0] = bBlue;
  72. pbDestPixel[1] = bGreen;
  73. pbDestPixel[2] = bRed;
  74. pbDestPixel += 3;
  75. }
  76. pbSrcPixel += 3*nDeltaX;
  77. }
  78. if( nPartialPixelWidth > 0 )
  79. {
  80. bRed = pbSrcPixel[2];
  81. bGreen = pbSrcPixel[1];
  82. bBlue = pbSrcPixel[0];
  83. pbDestPixel = pbSrcPixel+3;
  84. for( iDestPixel = 1; iDestPixel < nPartialPixelWidth; iDestPixel++ )
  85. {
  86. pbDestPixel[0] = bBlue;
  87. pbDestPixel[1] = bGreen;
  88. pbDestPixel[2] = bRed;
  89. pbDestPixel += 3;
  90. }
  91. }
  92. }
  93. void DuplicateScanLineIndex8( void* pScanLine, ULONG nDeltaX,
  94. ULONG nFullPixels, ULONG nFullPixelWidth, ULONG nPartialPixelWidth )
  95. {
  96. BYTE* pbSrcPixel;
  97. BYTE* pbDestPixel;
  98. ULONG iSrcPixel;
  99. ULONG iDestPixel;
  100. BYTE bIndex;
  101. pbSrcPixel = LPBYTE( pScanLine );
  102. for( iSrcPixel = 0; iSrcPixel < nFullPixels; iSrcPixel++ )
  103. {
  104. bIndex = pbSrcPixel[0];
  105. pbDestPixel = pbSrcPixel+1;
  106. for( iDestPixel = 1; iDestPixel < nFullPixelWidth; iDestPixel++ )
  107. {
  108. pbDestPixel[0] = bIndex;
  109. pbDestPixel++;
  110. }
  111. pbSrcPixel += nDeltaX;
  112. }
  113. if( nPartialPixelWidth > 0 )
  114. {
  115. bIndex = pbSrcPixel[0];
  116. pbDestPixel = pbSrcPixel+1;
  117. for( iDestPixel = 1; iDestPixel < nPartialPixelWidth; iDestPixel++ )
  118. {
  119. pbDestPixel[0] = bIndex;
  120. pbDestPixel++;
  121. }
  122. }
  123. }
  124. const float RECIP65535 = 1.0f/65535.0f;
  125. const float RECIP255 = 1.0f/255.0f;
  126. void CopyScanLineRGBA64ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  127. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  128. {
  129. const BYTE* pbSrc;
  130. BYTE* pbDest;
  131. ULONG iPixel;
  132. float fAlpha;
  133. float fInverseAlpha;
  134. float fSrcRed;
  135. float fSrcGreen;
  136. float fSrcBlue;
  137. float fDestRed;
  138. float fDestGreen;
  139. float fDestBlue;
  140. pbSrc = (const BYTE*)pSrc;
  141. pbDest = LPBYTE( pDest );
  142. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  143. {
  144. fAlpha = ((pbSrc[6]<<8)+pbSrc[7])*RECIP65535;
  145. fInverseAlpha = 1.0f-fAlpha;
  146. fSrcRed = ((pbSrc[0]<<8)+pbSrc[1])*RECIP65535;
  147. fSrcGreen = ((pbSrc[2]<<8)+pbSrc[3])*RECIP65535;
  148. fSrcBlue = ((pbSrc[4]<<8)+pbSrc[5])*RECIP65535;
  149. fDestRed = (fAlpha*fSrcRed)+(fInverseAlpha*pfrgbBackground->fRed);
  150. fDestGreen = (fAlpha*fSrcGreen)+(fInverseAlpha*pfrgbBackground->fGreen);
  151. fDestBlue = (fAlpha*fSrcBlue)+(fInverseAlpha*pfrgbBackground->fBlue);
  152. pbDest[0] = pXlate[BYTE(fDestBlue*255.0f)];
  153. pbDest[1] = pXlate[BYTE(fDestGreen*255.0f)];
  154. pbDest[2] = pXlate[BYTE(fDestRed*255.0f)];
  155. pbSrc += 8;
  156. pbDest += 3*nDeltaXDest;
  157. }
  158. }
  159. void CopyScanLineRGBA32ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  160. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  161. {
  162. const BYTE* pbSrc;
  163. BYTE* pbDest;
  164. ULONG iPixel;
  165. float fAlpha;
  166. float fInverseAlpha;
  167. float fSrcRed;
  168. float fSrcGreen;
  169. float fSrcBlue;
  170. float fDestRed;
  171. float fDestGreen;
  172. float fDestBlue;
  173. pbSrc = (const BYTE*)pSrc;
  174. pbDest = LPBYTE( pDest );
  175. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  176. {
  177. fAlpha = pbSrc[3]*RECIP255;
  178. fInverseAlpha = 1.0f-fAlpha;
  179. fSrcRed = pbSrc[0]*RECIP255;
  180. fSrcGreen = pbSrc[1]*RECIP255;
  181. fSrcBlue = pbSrc[2]*RECIP255;
  182. fDestRed = (fAlpha*fSrcRed)+(fInverseAlpha*pfrgbBackground->fRed);
  183. fDestGreen = (fAlpha*fSrcGreen)+(fInverseAlpha*pfrgbBackground->fGreen);
  184. fDestBlue = (fAlpha*fSrcBlue)+(fInverseAlpha*pfrgbBackground->fBlue);
  185. pbDest[0] = pXlate[BYTE(fDestBlue*255.0f)];
  186. pbDest[1] = pXlate[BYTE(fDestGreen*255.0f)];
  187. pbDest[2] = pXlate[BYTE(fDestRed*255.0f)];
  188. pbSrc += 4;
  189. pbDest += 3*nDeltaXDest;
  190. }
  191. }
  192. void CopyScanLineGrayA32ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  193. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  194. {
  195. const BYTE* pbSrc;
  196. BYTE* pbDest;
  197. ULONG iPixel;
  198. float fAlpha;
  199. float fInverseAlpha;
  200. float fSrc;
  201. float fDest;
  202. BYTE bDest;
  203. pbSrc = (const BYTE*)pSrc;
  204. pbDest = LPBYTE( pDest );
  205. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  206. {
  207. fAlpha = ((pbSrc[2]<<8)+pbSrc[3])*RECIP65535;
  208. fInverseAlpha = 1.0f-fAlpha;
  209. fSrc = ((pbSrc[0]<<8)+pbSrc[1])*RECIP65535;
  210. fDest = (fAlpha*fSrc)+(fInverseAlpha*pfrgbBackground->fRed);
  211. bDest = pXlate[BYTE(fDest*255.0f)];
  212. pbDest[0] = bDest;
  213. pbDest[1] = bDest;
  214. pbDest[2] = bDest;
  215. pbSrc += 4;
  216. pbDest += 3*nDeltaXDest;
  217. }
  218. }
  219. void CopyScanLineGrayA16ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  220. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  221. {
  222. const BYTE* pbSrc;
  223. BYTE* pbDest;
  224. ULONG iPixel;
  225. float fAlpha;
  226. float fInverseAlpha;
  227. float fSrc;
  228. float fDest;
  229. BYTE bDest;
  230. pbSrc = (const BYTE*)pSrc;
  231. pbDest = LPBYTE( pDest );
  232. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  233. {
  234. fAlpha = pbSrc[1]*RECIP255;
  235. fInverseAlpha = 1.0f-fAlpha;
  236. fSrc = pbSrc[0]*RECIP255;
  237. fDest = (fAlpha*fSrc)+(fInverseAlpha*pfrgbBackground->fRed);
  238. bDest = pXlate[BYTE(fDest*255.0f)];
  239. pbDest[0] = bDest;
  240. pbDest[1] = bDest;
  241. pbDest[2] = bDest;
  242. pbSrc += 2;
  243. pbDest += 3*nDeltaXDest;
  244. }
  245. }
  246. void CopyScanLineRGBA64ToBGRA32( void* pDest, const void* pSrc, ULONG nPixels,
  247. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  248. {
  249. const BYTE* pbSrc;
  250. BYTE* pbDest;
  251. ULONG iPixel;
  252. (void)pfrgbBackground;
  253. pbSrc = (const BYTE*)pSrc;
  254. pbDest = LPBYTE( pDest );
  255. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  256. {
  257. pbDest[0] = pXlate[pbSrc[4]];
  258. pbDest[1] = pXlate[pbSrc[2]];
  259. pbDest[2] = pXlate[pbSrc[0]];
  260. pbDest[3] = pbSrc[6]; // alpha not gamma corrected
  261. pbSrc += 8;
  262. pbDest += 4*nDeltaXDest;
  263. }
  264. }
  265. void CopyScanLineRGB48ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  266. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  267. {
  268. const BYTE* pbSrc;
  269. BYTE* pbDest;
  270. ULONG iPixel;
  271. (void)pfrgbBackground;
  272. pbSrc = (const BYTE*)pSrc;
  273. pbDest = LPBYTE( pDest );
  274. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  275. {
  276. pbDest[0] = pXlate[pbSrc[4]];
  277. pbDest[1] = pXlate[pbSrc[2]];
  278. pbDest[2] = pXlate[pbSrc[0]];
  279. pbSrc += 6;
  280. pbDest += 3*nDeltaXDest;
  281. }
  282. }
  283. void CopyScanLineRGBA32ToBGRA32( void* pDest, const void* pSrc, ULONG nPixels,
  284. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  285. {
  286. const BYTE* pbSrc;
  287. BYTE* pbDest;
  288. ULONG iPixel;
  289. (void)pfrgbBackground;
  290. pbSrc = (const BYTE*)pSrc;
  291. pbDest = LPBYTE( pDest );
  292. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  293. {
  294. pbDest[0] = pXlate[pbSrc[2]];
  295. pbDest[1] = pXlate[pbSrc[1]];
  296. pbDest[2] = pXlate[pbSrc[0]];
  297. pbDest[3] = pbSrc[3]; // alpha not gamma corrected
  298. pbSrc += 4;
  299. pbDest += 4*nDeltaXDest;
  300. }
  301. }
  302. void CopyScanLineRGB24ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  303. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  304. {
  305. const BYTE* pbSrc;
  306. BYTE* pbDest;
  307. ULONG iPixel;
  308. (void)pfrgbBackground;
  309. pbSrc = (const BYTE*)pSrc;
  310. pbDest = LPBYTE( pDest );
  311. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  312. {
  313. pbDest[0] = pXlate[pbSrc[2]];
  314. pbDest[1] = pXlate[pbSrc[1]];
  315. pbDest[2] = pXlate[pbSrc[0]];
  316. pbSrc += 3;
  317. pbDest += 3*nDeltaXDest;
  318. }
  319. }
  320. void CopyScanLineGrayA32ToBGRA32( void* pDest, const void* pSrc, ULONG nPixels,
  321. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  322. {
  323. const BYTE* pbSrc;
  324. BYTE* pbDest;
  325. ULONG iPixel;
  326. (void)pfrgbBackground;
  327. pbSrc = (const BYTE*)pSrc;
  328. pbDest = LPBYTE( pDest );
  329. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  330. {
  331. pbDest[0] = pXlate[pbSrc[0]];
  332. pbDest[1] = pbDest[0];
  333. pbDest[2] = pbDest[0];
  334. pbDest[3] = pbSrc[2]; // alpha not gamma corrected
  335. pbSrc += 4;
  336. pbDest += 4*nDeltaXDest;
  337. }
  338. }
  339. void CopyScanLineGray16ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  340. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  341. {
  342. const BYTE* pbSrc;
  343. BYTE* pbDest;
  344. ULONG iPixel;
  345. (void)pfrgbBackground;
  346. pbSrc = (const BYTE*)pSrc;
  347. pbDest = LPBYTE( pDest );
  348. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  349. {
  350. pbDest[0] = pXlate[pbSrc[0]];
  351. pbDest[1] = pbDest[0];
  352. pbDest[2] = pbDest[0];
  353. pbSrc += 2;
  354. pbDest += 3*nDeltaXDest;
  355. }
  356. }
  357. void CopyScanLineGrayA16ToBGRA32( void* pDest, const void* pSrc, ULONG nPixels,
  358. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  359. {
  360. const BYTE* pbSrc;
  361. BYTE* pbDest;
  362. ULONG iPixel;
  363. (void)pfrgbBackground;
  364. pbSrc = (const BYTE*)pSrc;
  365. pbDest = LPBYTE( pDest );
  366. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  367. {
  368. pbDest[0] = pXlate[pbSrc[0]];
  369. pbDest[1] = pbDest[0];
  370. pbDest[2] = pbDest[0];
  371. pbDest[3] = pbSrc[1];
  372. pbSrc += 2;
  373. pbDest += 4*nDeltaXDest;
  374. }
  375. }
  376. void CopyScanLineGray8ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  377. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  378. {
  379. const BYTE* pbSrc;
  380. BYTE* pbDest;
  381. ULONG iPixel;
  382. (void)pfrgbBackground;
  383. pbSrc = (const BYTE*)pSrc;
  384. pbDest = LPBYTE( pDest );
  385. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  386. {
  387. pbDest[0] = pXlate[pbSrc[0]];
  388. pbDest[1] = pbDest[0];
  389. pbDest[2] = pbDest[0];
  390. pbSrc++;
  391. pbDest += 3*nDeltaXDest;
  392. }
  393. }
  394. void CopyScanLineGray8ToGray8( void* pDest, const void* pSrc, ULONG nPixels,
  395. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  396. {
  397. const BYTE* pbSrc;
  398. BYTE* pbDest;
  399. ULONG iPixel;
  400. (void)pfrgbBackground;
  401. pbSrc = (const BYTE*)pSrc;
  402. pbDest = LPBYTE( pDest );
  403. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  404. {
  405. pbDest[0] = pXlate[pbSrc[0]];
  406. pbSrc++;
  407. pbDest += nDeltaXDest;
  408. }
  409. }
  410. static inline BYTE Expand4To8( ULONG nIntensity )
  411. {
  412. return( BYTE( nIntensity+(nIntensity<<4) ) );
  413. }
  414. void CopyScanLineGray4ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  415. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  416. {
  417. const BYTE* pbSrc;
  418. BYTE* pbDest;
  419. ULONG iPair;
  420. ULONG nPairs;
  421. BYTE bSrc;
  422. BYTE bDest;
  423. (void)pfrgbBackground;
  424. pbSrc = (const BYTE*)pSrc;
  425. pbDest = LPBYTE( pDest );
  426. nPairs = nPixels/2;
  427. for( iPair = 0; iPair < nPairs; iPair++ )
  428. {
  429. bSrc = pbSrc[0];
  430. bDest = pXlate[BYTE((bSrc & 0xf0) + ((bSrc & 0xf0) >> 4))];
  431. pbDest[0] = bDest;
  432. pbDest[1] = bDest;
  433. pbDest[2] = bDest;
  434. pbDest += 3*nDeltaXDest;
  435. bDest = pXlate[BYTE((bSrc & 0x0f) + ((bSrc & 0x0f) << 4))];
  436. pbDest[0] = bDest;
  437. pbDest[1] = bDest;
  438. pbDest[2] = bDest;
  439. pbDest += 3*nDeltaXDest;
  440. pbSrc++;
  441. }
  442. if( (nPixels%2) > 0 )
  443. {
  444. bSrc = pbSrc[0];
  445. bDest = pXlate[BYTE((bSrc & 0xf0) + ((bSrc & 0xf0) >> 4))];
  446. pbDest[0] = bDest;
  447. pbDest[1] = bDest;
  448. pbDest[2] = bDest;
  449. }
  450. }
  451. static BYTE g_abExpand2To8[4] = { 0, 85, 170, 255 };
  452. static inline BYTE Expand2To8( ULONG nIntensity )
  453. {
  454. return( g_abExpand2To8[nIntensity] );
  455. }
  456. void CopyScanLineGray2ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  457. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  458. {
  459. const BYTE* pbSrc;
  460. BYTE* pbDest;
  461. ULONG iQuad;
  462. ULONG nQuads;
  463. ULONG iPixel;
  464. ULONG nShift;
  465. ULONG nExtraPixels;
  466. BYTE bSrc;
  467. BYTE bDest;
  468. (void)pfrgbBackground;
  469. pbSrc = (const BYTE*)pSrc;
  470. pbDest = LPBYTE( pDest );
  471. nQuads = nPixels/4;
  472. for( iQuad = 0; iQuad < nQuads; iQuad++ )
  473. {
  474. bSrc = pbSrc[0];
  475. nShift = 6;
  476. for( iPixel = 0; iPixel < 4; iPixel++ )
  477. {
  478. bDest = pXlate[Expand2To8((bSrc >> nShift) & 0x03)];
  479. pbDest[0] = bDest;
  480. pbDest[1] = bDest;
  481. pbDest[2] = bDest;
  482. nShift -= 2;
  483. pbDest += 3*nDeltaXDest;
  484. }
  485. pbSrc++;
  486. }
  487. nExtraPixels = nPixels%4;
  488. if( nExtraPixels > 0 )
  489. {
  490. nShift = 6;
  491. bSrc = pbSrc[0];
  492. for( iPixel = 0; iPixel < nExtraPixels; iPixel++ )
  493. {
  494. bDest = pXlate[Expand2To8((bSrc >> nShift) & 0x03)];
  495. pbDest[0] = bDest;
  496. pbDest[1] = bDest;
  497. pbDest[2] = bDest;
  498. nShift -= 2;
  499. pbDest += 3*nDeltaXDest;
  500. }
  501. }
  502. }
  503. static BYTE g_abExpand1To8[2] = { 0, 255 };
  504. static inline BYTE Expand1To8( ULONG nIntensity )
  505. {
  506. return( g_abExpand1To8[nIntensity] );
  507. }
  508. void CopyScanLineGray1ToBGR24( void* pDest, const void* pSrc, ULONG nPixels,
  509. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  510. {
  511. const BYTE* pbSrc;
  512. BYTE* pbDest;
  513. ULONG iOctet;
  514. ULONG nOctets;
  515. ULONG nShift;
  516. ULONG nExtraPixels;
  517. ULONG iPixel;
  518. BYTE bSrc;
  519. BYTE bDest;
  520. (void)pfrgbBackground;
  521. (void)pXlate;
  522. pbSrc = (const BYTE*)pSrc;
  523. pbDest = LPBYTE( pDest );
  524. nOctets = nPixels/8;
  525. for( iOctet = 0; iOctet < nOctets; iOctet++ )
  526. {
  527. bSrc = pbSrc[0];
  528. nShift = 7;
  529. for( iPixel = 0; iPixel < 8; iPixel++ )
  530. {
  531. bDest = Expand1To8( (bSrc>>nShift)&0x01 );
  532. pbDest[0] = bDest;
  533. pbDest[1] = bDest;
  534. pbDest[2] = bDest;
  535. nShift--;
  536. pbDest += 3*nDeltaXDest;
  537. }
  538. pbSrc++;
  539. }
  540. nExtraPixels = nPixels%8;
  541. if( nExtraPixels > 0 )
  542. {
  543. nShift = 7;
  544. bSrc = pbSrc[0];
  545. for( iPixel = 0; iPixel < nExtraPixels; iPixel++ )
  546. {
  547. bDest = Expand1To8( (bSrc>>nShift)&0x01 );
  548. pbDest[0] = bDest;
  549. pbDest[1] = bDest;
  550. pbDest[2] = bDest;
  551. nShift--;
  552. pbDest += 3*nDeltaXDest;
  553. }
  554. }
  555. }
  556. void CopyScanLineIndex8ToIndex8( void* pDest, const void* pSrc, ULONG nPixels,
  557. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  558. {
  559. const BYTE* pbSrc;
  560. BYTE* pbDest;
  561. ULONG iPixel;
  562. (void)pfrgbBackground;
  563. pbSrc = (const BYTE*)pSrc;
  564. pbDest = LPBYTE( pDest );
  565. for( iPixel = 0; iPixel < nPixels; iPixel++ )
  566. {
  567. pbDest[0] = pXlate[pbSrc[0]];
  568. pbSrc++;
  569. pbDest += nDeltaXDest;
  570. }
  571. }
  572. void CopyScanLineIndex4ToIndex8( void* pDest, const void* pSrc, ULONG nPixels,
  573. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  574. {
  575. const BYTE* pbSrc;
  576. BYTE* pbDest;
  577. ULONG iPair;
  578. ULONG nPairs;
  579. BYTE bSrc;
  580. (void)pfrgbBackground;
  581. pbSrc = (const BYTE*)pSrc;
  582. pbDest = LPBYTE( pDest );
  583. nPairs = nPixels/2;
  584. for( iPair = 0; iPair < nPairs; iPair++ )
  585. {
  586. bSrc = pbSrc[0];
  587. pbDest[0] = pXlate[BYTE((bSrc >> 4) & 0x0f)];
  588. pbDest[nDeltaXDest] = pXlate[BYTE(bSrc & 0x0f)];
  589. pbSrc++;
  590. pbDest += 2*nDeltaXDest;
  591. }
  592. if( (nPixels%2) > 0 )
  593. {
  594. pbDest[0] = pXlate[BYTE((pbSrc[0] >> 4) & 0x0f)];
  595. }
  596. }
  597. void CopyScanLineIndex2ToIndex8( void* pDest, const void* pSrc, ULONG nPixels,
  598. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate )
  599. {
  600. const BYTE* pbSrc;
  601. BYTE* pbDest;
  602. ULONG iQuad;
  603. ULONG nQuads;
  604. ULONG nShift;
  605. ULONG nExtraPixels;
  606. ULONG iPixel;
  607. BYTE bSrc;
  608. (void)pfrgbBackground;
  609. pbSrc = (const BYTE*)pSrc;
  610. pbDest = LPBYTE( pDest );
  611. nQuads = nPixels/4;
  612. for( iQuad = 0; iQuad < nQuads; iQuad++ )
  613. {
  614. bSrc = pbSrc[0];
  615. pbDest[0] = pXlate[BYTE((bSrc>>6) & 0x03)];
  616. pbDest[nDeltaXDest] = pXlate[BYTE((bSrc >> 4) & 0x03)];
  617. pbDest[2*nDeltaXDest] = pXlate[BYTE((bSrc >> 2) & 0x03)];
  618. pbDest[3*nDeltaXDest] = pXlate[BYTE(bSrc & 0x03)];
  619. pbSrc++;
  620. pbDest += 4*nDeltaXDest;
  621. }
  622. nExtraPixels = nPixels%4;
  623. if( nExtraPixels > 0 )
  624. {
  625. nShift = 6;
  626. bSrc = pbSrc[0];
  627. for( iPixel = 0; iPixel < nExtraPixels; iPixel++ )
  628. {
  629. pbDest[0] = pXlate[BYTE((bSrc >> nShift) & 0x03)];
  630. nShift -= 2;
  631. pbDest += nDeltaXDest;
  632. }
  633. }
  634. }
  635. void CopyScanLineIndex1ToIndex8( void* pDest, const void* pSrc, ULONG nPixels,
  636. ULONG nDeltaXDest, const FLOATRGB* pfrgbBackground, BYTE *pXlate)
  637. {
  638. const BYTE* pbSrc;
  639. BYTE* pbDest;
  640. ULONG iOctet;
  641. ULONG nOctets;
  642. ULONG nShift;
  643. ULONG nExtraPixels;
  644. ULONG iPixel;
  645. BYTE bSrc;
  646. (void)pfrgbBackground;
  647. pbSrc = (const BYTE*)pSrc;
  648. pbDest = LPBYTE( pDest );
  649. nOctets = nPixels/8;
  650. for( iOctet = 0; iOctet < nOctets; iOctet++ )
  651. {
  652. bSrc = pbSrc[0];
  653. nShift = 7;
  654. for( iPixel = 0; iPixel < 8; iPixel++ )
  655. {
  656. pbDest[0] = pXlate[BYTE((bSrc>>nShift) &0x01)];
  657. nShift--;
  658. pbDest += nDeltaXDest;
  659. }
  660. pbSrc++;
  661. }
  662. nExtraPixels = nPixels%8;
  663. if( nExtraPixels > 0 )
  664. {
  665. nShift = 7;
  666. bSrc = pbSrc[0];
  667. for( iPixel = 0; iPixel < nExtraPixels; iPixel++ )
  668. {
  669. pbDest[0] = pXlate[BYTE((bSrc>>nShift) &0x01)];
  670. nShift--;
  671. pbDest += nDeltaXDest;
  672. }
  673. }
  674. }