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.

1115 lines
21 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: tranblt.cxx
  3. *
  4. * Transparent BLT
  5. *
  6. * Created: 21-Jun-1996
  7. * Author: Mark Enstrom [marke]
  8. *
  9. * Copyright (c) 1996-1999 Microsoft Corporation
  10. \**************************************************************************/
  11. #include "precomp.hxx"
  12. #if !(_WIN32_WINNT >= 0x500)
  13. /******************************Public*Routine******************************\
  14. * Routines to load a pixel and convert it to BGRA representaion for
  15. * blending operations
  16. *
  17. * Arguments:
  18. *
  19. *
  20. *
  21. * Return Value:
  22. *
  23. *
  24. *
  25. * History:
  26. *
  27. * 12/2/1996 Mark Enstrom [marke]
  28. *
  29. \**************************************************************************/
  30. VOID
  31. vLoadAndConvert1ToBGRA(
  32. PULONG pulDstAddr,
  33. PBYTE pSrcAddr,
  34. LONG SrcX,
  35. LONG SrcCx,
  36. PVOID ppalInfo
  37. )
  38. {
  39. BYTE SrcByte;
  40. LONG cxUnalignedStart = 7 & (8 - (SrcX & 7));
  41. PULONG ppal = (PULONG)&((PPALINFO)ppalInfo)->pBitmapInfo->bmiColors[0];
  42. pSrcAddr = pSrcAddr + (SrcX >> 3);
  43. cxUnalignedStart = MIN(SrcCx,cxUnalignedStart);
  44. //
  45. // unaligned start
  46. //
  47. if (cxUnalignedStart)
  48. {
  49. LONG iDst = 7 - (SrcX & 0x07);
  50. SrcByte = *pSrcAddr;
  51. pSrcAddr++;
  52. while (cxUnalignedStart--)
  53. {
  54. ULONG ulSrc = ((SrcByte & (1 << iDst)) >> iDst);
  55. ulSrc = ppal[ulSrc] | 0xFF000000;
  56. *pulDstAddr = ulSrc;
  57. pulDstAddr++;
  58. SrcCx--;
  59. iDst--;
  60. }
  61. }
  62. //
  63. // aligned whole bytes
  64. //
  65. while (SrcCx >= 8)
  66. {
  67. SrcCx -= 8;
  68. SrcByte = *pSrcAddr;
  69. *(pulDstAddr + 0) = (ppal[(SrcByte & 0x80) >> 7] | 0xff000000);
  70. *(pulDstAddr + 1) = (ppal[(SrcByte & 0x40) >> 6] | 0xff000000);
  71. *(pulDstAddr + 2) = (ppal[(SrcByte & 0x20) >> 5] | 0xff000000);
  72. *(pulDstAddr + 3) = (ppal[(SrcByte & 0x10) >> 4] | 0xff000000);
  73. *(pulDstAddr + 4) = (ppal[(SrcByte & 0x08) >> 3] | 0xff000000);
  74. *(pulDstAddr + 5) = (ppal[(SrcByte & 0x04) >> 2] | 0xff000000);
  75. *(pulDstAddr + 6) = (ppal[(SrcByte & 0x02) >> 1] | 0xff000000);
  76. *(pulDstAddr + 7) = (ppal[(SrcByte & 0x01) >> 0] | 0xff000000);
  77. pSrcAddr++;
  78. pulDstAddr+=8;
  79. }
  80. //
  81. // unaligned end
  82. //
  83. if (SrcCx)
  84. {
  85. BYTE SrcByte = *pSrcAddr;
  86. LONG iDst = 7;
  87. while (SrcCx)
  88. {
  89. ULONG ulSrc = ((SrcByte & (1 << iDst)) >> iDst);
  90. ulSrc = ppal[ulSrc] | 0xff000000;
  91. *pulDstAddr = ulSrc;
  92. pulDstAddr++;
  93. SrcCx--;
  94. iDst--;
  95. }
  96. }
  97. }
  98. /**************************************************************************\
  99. * vLoadAndConvert4ToBGRA
  100. *
  101. *
  102. * Arguments:
  103. *
  104. *
  105. *
  106. * Return Value:
  107. *
  108. *
  109. *
  110. * History:
  111. *
  112. * 1/22/1997 Mark Enstrom [marke]
  113. *
  114. \**************************************************************************/
  115. VOID
  116. vLoadAndConvert4ToBGRA(
  117. PULONG pulDstAddr,
  118. PBYTE pSrcAddr,
  119. LONG SrcX,
  120. LONG SrcCx,
  121. PVOID ppalInfo
  122. )
  123. {
  124. BYTE SrcByte;
  125. pSrcAddr = pSrcAddr + (SrcX >> 1);
  126. LONG cxUnalignedStart = 1 & (2 - (SrcX & 1));
  127. PULONG ppal = (PULONG)&((PPALINFO)ppalInfo)->pBitmapInfo->bmiColors[0];
  128. cxUnalignedStart = MIN(SrcCx,cxUnalignedStart);
  129. //
  130. // unaligned start
  131. //
  132. if (cxUnalignedStart)
  133. {
  134. SrcByte = *pSrcAddr;
  135. *pulDstAddr = ppal[SrcByte & 0x0f] | 0xff000000;
  136. pSrcAddr++;
  137. pulDstAddr++;
  138. SrcCx--;
  139. }
  140. //
  141. // aligned whole bytes
  142. //
  143. while (SrcCx >= 2)
  144. {
  145. SrcCx -= 2;
  146. SrcByte = *pSrcAddr;
  147. *(pulDstAddr + 0) = ppal[(SrcByte >> 4) ] | 0xff000000;
  148. *(pulDstAddr + 1) = ppal[(SrcByte & 0x0f)] | 0xff000000;
  149. pSrcAddr++;
  150. pulDstAddr+=2;
  151. }
  152. //
  153. // unaligned end
  154. //
  155. if (SrcCx)
  156. {
  157. SrcByte = *pSrcAddr;
  158. *pulDstAddr = ppal[SrcByte >> 4] | 0xff000000;
  159. }
  160. }
  161. /**************************************************************************\
  162. * vLoadAndConvert8ToBGRA
  163. *
  164. *
  165. * Arguments:
  166. *
  167. *
  168. *
  169. * Return Value:
  170. *
  171. *
  172. *
  173. * History:
  174. *
  175. * 1/22/1997 Mark Enstrom [marke]
  176. *
  177. \**************************************************************************/
  178. VOID
  179. vLoadAndConvert8ToBGRA(
  180. PULONG pulDstAddr,
  181. PBYTE pSrcAddr,
  182. LONG SrcX,
  183. LONG SrcCx,
  184. PVOID ppalInfo
  185. )
  186. {
  187. PBYTE pjSrc = pSrcAddr + SrcX;
  188. PBYTE pjEnd = pjSrc + SrcCx;
  189. PULONG ppal = (PULONG)&((PPALINFO)ppalInfo)->pBitmapInfo->bmiColors[0];
  190. while (pjSrc != pjEnd)
  191. {
  192. *pulDstAddr = ppal[*pjSrc] | 0xff000000;
  193. pulDstAddr++;
  194. pjSrc++;
  195. }
  196. }
  197. /**************************************************************************\
  198. * vLoadAndConvertRGB16_565ToBGRA
  199. *
  200. *
  201. * Arguments:
  202. *
  203. *
  204. *
  205. * Return Value:
  206. *
  207. *
  208. *
  209. * History:
  210. *
  211. * 1/22/1997 Mark Enstrom [marke]
  212. *
  213. \**************************************************************************/
  214. VOID
  215. vLoadAndConvertRGB16_565ToBGRA(
  216. PULONG pulDstAddr,
  217. PBYTE pSrcAddr,
  218. LONG SrcX,
  219. LONG SrcCx,
  220. PVOID ppalInfo
  221. )
  222. {
  223. PUSHORT pusSrc = (PUSHORT)pSrcAddr + SrcX;
  224. PUSHORT pusEnd = pusSrc + SrcCx;
  225. while (pusSrc != pusEnd)
  226. {
  227. ALPHAPIX pixIn;
  228. ALPHAPIX pixOut;
  229. pixIn.ul = *pusSrc;
  230. pixOut.pix.r = (BYTE)((pixIn.ul & 0xf800) >> 8);
  231. pixOut.pix.g = (BYTE)((pixIn.ul & 0x07e0) >> 3);
  232. pixOut.pix.b = (BYTE)((pixIn.ul & 0x001f) << 3);
  233. pixOut.pix.a = 0xff;
  234. *pulDstAddr = pixOut.ul;
  235. pusSrc++;
  236. pulDstAddr++;
  237. }
  238. }
  239. /**************************************************************************\
  240. * vLoadAndConvertRGB16_555ToBGRA
  241. *
  242. *
  243. * Arguments:
  244. *
  245. *
  246. *
  247. * Return Value:
  248. *
  249. *
  250. *
  251. * History:
  252. *
  253. * 1/22/1997 Mark Enstrom [marke]
  254. *
  255. \**************************************************************************/
  256. VOID
  257. vLoadAndConvertRGB16_555ToBGRA(
  258. PULONG pulDstAddr,
  259. PBYTE pSrcAddr,
  260. LONG SrcX,
  261. LONG SrcCx,
  262. PVOID ppalInfo
  263. )
  264. {
  265. PUSHORT pusSrc = (PUSHORT)pSrcAddr + SrcX;
  266. PUSHORT pusEnd = pusSrc + SrcCx;
  267. while (pusSrc != pusEnd)
  268. {
  269. ALPHAPIX pixIn;
  270. ALPHAPIX pixOut;
  271. pixIn.ul = *pusSrc;
  272. pixOut.pix.r = (BYTE)((pixIn.ul & 0x7c00) >> 7);
  273. pixOut.pix.g = (BYTE)((pixIn.ul & 0x03e0) >> 2);
  274. pixOut.pix.b = (BYTE)((pixIn.ul & 0x001f) << 3);
  275. pixOut.pix.a = 0xff;
  276. *pulDstAddr = pixOut.ul;
  277. pusSrc++;
  278. pulDstAddr++;
  279. }
  280. }
  281. /**************************************************************************\
  282. * vLoadAndConvert16BitfieldsToBGRA
  283. *
  284. *
  285. * Arguments:
  286. *
  287. *
  288. *
  289. * Return Value:
  290. *
  291. *
  292. *
  293. * History:
  294. *
  295. * 1/22/1997 Mark Enstrom [marke]
  296. *
  297. \**************************************************************************/
  298. VOID
  299. vLoadAndConvert16BitfieldsToBGRA(
  300. PULONG pulDstAddr,
  301. PBYTE pSrcAddr,
  302. LONG SrcX,
  303. LONG SrcCx,
  304. PVOID ppalInfo
  305. )
  306. {
  307. PUSHORT pusSrc = (PUSHORT)pSrcAddr + SrcX;
  308. PUSHORT pusEnd = pusSrc + SrcCx;
  309. while (pusSrc != pusEnd)
  310. {
  311. ULONG ulTmp;
  312. ulTmp = *pusSrc;
  313. //ulTmp = ppal.ulBitfieldToRGB(ulTmp);
  314. ulTmp |= 0xff000000;
  315. *pulDstAddr = ulTmp;
  316. pusSrc++;
  317. pulDstAddr++;
  318. }
  319. }
  320. /**************************************************************************\
  321. * vLoadAndConvertRGB24ToBGRA
  322. *
  323. *
  324. * Arguments:
  325. *
  326. *
  327. *
  328. * Return Value:
  329. *
  330. *
  331. *
  332. * History:
  333. *
  334. * 1/22/1997 Mark Enstrom [marke]
  335. *
  336. \**************************************************************************/
  337. VOID
  338. vLoadAndConvertRGB24ToBGRA(
  339. PULONG pulDstAddr,
  340. PBYTE pSrcAddr,
  341. LONG SrcX,
  342. LONG SrcCx,
  343. PVOID ppalInfo
  344. )
  345. {
  346. PBYTE pjSrc = pSrcAddr + 3 * SrcX;
  347. PBYTE pjEnd = pjSrc + 3 * SrcCx;
  348. while (pjSrc != pjEnd)
  349. {
  350. ALPHAPIX pixRet;
  351. pixRet.pix.b = *(((PBYTE)pjSrc));
  352. pixRet.pix.g = *(((PBYTE)pjSrc)+1);
  353. pixRet.pix.r = *(((PBYTE)pjSrc)+2);
  354. pixRet.pix.a = 0xff;
  355. *pulDstAddr = pixRet.ul;
  356. pjSrc += 3;
  357. pulDstAddr++;
  358. }
  359. }
  360. /**************************************************************************\
  361. * vLoadAndConvertRGB32ToBGRA
  362. *
  363. *
  364. * Arguments:
  365. *
  366. *
  367. *
  368. * Return Value:
  369. *
  370. *
  371. *
  372. * History:
  373. *
  374. * 1/22/1997 Mark Enstrom [marke]
  375. *
  376. \**************************************************************************/
  377. VOID
  378. vLoadAndConvertRGB32ToBGRA(
  379. PULONG pulDstAddr,
  380. PBYTE pSrcAddr,
  381. LONG SrcX,
  382. LONG SrcCx,
  383. PVOID ppalInfo
  384. )
  385. {
  386. PULONG pulSrc = (PULONG)pSrcAddr + SrcX;
  387. PULONG pulEnd = pulSrc + SrcCx;
  388. while (pulSrc != pulEnd)
  389. {
  390. ALPHAPIX pixIn;
  391. ALPHAPIX pixOut;
  392. pixIn.ul = *pulSrc;
  393. pixOut.pix.r = pixIn.pix.b;
  394. pixOut.pix.g = pixIn.pix.g;
  395. pixOut.pix.b = pixIn.pix.r;
  396. pixOut.pix.a = pixIn.pix.a;
  397. *pulDstAddr = pixOut.ul;
  398. pulSrc++;
  399. pulDstAddr++;
  400. }
  401. }
  402. /**************************************************************************\
  403. * vLoadAndConvert32BitfieldsToBGRA
  404. *
  405. *
  406. * Arguments:
  407. *
  408. *
  409. *
  410. * Return Value:
  411. *
  412. *
  413. *
  414. * History:
  415. *
  416. * 1/22/1997 Mark Enstrom [marke]
  417. *
  418. \**************************************************************************/
  419. VOID
  420. vLoadAndConvert32BitfieldsToBGRA(
  421. PULONG pulDstAddr,
  422. PBYTE pSrcAddr,
  423. LONG SrcX,
  424. LONG SrcCx,
  425. PVOID ppalInfo
  426. )
  427. {
  428. PULONG pulSrc = (PULONG)pSrcAddr + SrcX;
  429. PULONG pulEnd = pulSrc + SrcCx;
  430. while (pulSrc != pulEnd)
  431. {
  432. ULONG ulTmp;
  433. ulTmp = *pulSrc;
  434. //ulTmp = ppal.ulBitfieldToRGB(ulTmp);
  435. *pulDstAddr = ulTmp;
  436. pulSrc++;
  437. pulDstAddr++;
  438. }
  439. }
  440. //
  441. //
  442. // STORE ROUTINES
  443. // convert BGRA to RGB332, look up in table
  444. //
  445. #define PALETTE_MATCH(pixIn,ppalInfo) \
  446. { \
  447. pixIn.ul = ppalInfo->pxlate332[ \
  448. ((pixIn.pix.r & 0xe0)) | \
  449. ((pixIn.pix.g & 0xe0) >> 3) | \
  450. ((pixIn.pix.b & 0xc0) >> 6)]; \
  451. } \
  452. /**************************************************************************\
  453. * vConvertAndSaveBGRATo1
  454. *
  455. *
  456. * Arguments:
  457. *
  458. *
  459. *
  460. * Return Value:
  461. *
  462. *
  463. *
  464. * History:
  465. *
  466. * 1/22/1997 Mark Enstrom [marke]
  467. *
  468. \**************************************************************************/
  469. VOID
  470. vConvertAndSaveBGRATo1(
  471. PBYTE pDst,
  472. PULONG pulSrc,
  473. LONG cx,
  474. LONG DstX,
  475. PVOID pvpalInfo,
  476. PBYTE pWriteMask
  477. )
  478. {
  479. PPALINFO ppalInfo = (PPALINFO)pvpalInfo;
  480. PBYTE pjDst = pDst + (DstX >> 3);
  481. LONG iDst = DstX & 7;
  482. //
  483. // unaligned byte
  484. //
  485. if (iDst)
  486. {
  487. BYTE DstByte = *pjDst;
  488. LONG iShift = 7 - iDst;
  489. LONG cxUnaligned = iShift + 1;
  490. cxUnaligned = MIN(cxUnaligned,cx);
  491. cx -= cxUnaligned;
  492. while (cxUnaligned--)
  493. {
  494. ALPHAPIX pixIn;
  495. pixIn.ul = *pulSrc;
  496. PALETTE_MATCH(pixIn,ppalInfo);
  497. pixIn.ul = pixIn.ul << iShift;
  498. DstByte = DstByte & (~(1 << iShift));
  499. DstByte |= (BYTE)pixIn.ul;
  500. pulSrc++;
  501. iShift--;
  502. }
  503. *pjDst = DstByte;
  504. pjDst++;
  505. }
  506. //
  507. // aligned whole bytes
  508. //
  509. while (cx >= 8)
  510. {
  511. ALPHAPIX pixIn;
  512. BYTE DstByte;
  513. pixIn.ul = *pulSrc;
  514. PALETTE_MATCH(pixIn,ppalInfo);
  515. DstByte = (BYTE)(pixIn.ul << 7);
  516. pixIn.ul = *(pulSrc+1);
  517. PALETTE_MATCH(pixIn,ppalInfo);
  518. DstByte |= (BYTE)(pixIn.ul << 6);
  519. pixIn.ul = *(pulSrc+2);
  520. PALETTE_MATCH(pixIn,ppalInfo);
  521. DstByte |= (BYTE)(pixIn.ul << 5);
  522. pixIn.ul = *(pulSrc+3);
  523. PALETTE_MATCH(pixIn,ppalInfo);
  524. DstByte |= (BYTE)(pixIn.ul << 4);
  525. pixIn.ul = *(pulSrc+4);
  526. PALETTE_MATCH(pixIn,ppalInfo);
  527. DstByte |= (BYTE)(pixIn.ul << 3);
  528. pixIn.ul = *(pulSrc+5);
  529. PALETTE_MATCH(pixIn,ppalInfo);
  530. DstByte |= (BYTE)(pixIn.ul << 2);
  531. pixIn.ul = *(pulSrc+6);
  532. PALETTE_MATCH(pixIn,ppalInfo);
  533. DstByte |= (BYTE)(pixIn.ul << 1);
  534. pixIn.ul = *(pulSrc+7);
  535. PALETTE_MATCH(pixIn,ppalInfo);
  536. DstByte |= (BYTE)(pixIn.ul << 0);
  537. *pjDst = DstByte;
  538. pjDst++;
  539. pulSrc += 8;
  540. cx -= 8;
  541. }
  542. //
  543. // unaligned end
  544. //
  545. if (cx)
  546. {
  547. BYTE iShift = 7;
  548. BYTE DstByte = *pjDst;
  549. while (cx--)
  550. {
  551. ALPHAPIX pixIn;
  552. pixIn.ul = *pulSrc;
  553. PALETTE_MATCH(pixIn,ppalInfo);
  554. pixIn.ul = pixIn.ul << iShift;
  555. DstByte = DstByte & (~(1 << iShift));
  556. DstByte |= (BYTE)pixIn.ul;
  557. pulSrc++;
  558. iShift--;
  559. }
  560. *pjDst = DstByte;
  561. }
  562. }
  563. /**************************************************************************\
  564. * vConvertAndSaveBGRATo4
  565. *
  566. *
  567. * Arguments:
  568. *
  569. *
  570. *
  571. * Return Value:
  572. *
  573. *
  574. *
  575. * History:
  576. *
  577. * 1/22/1997 Mark Enstrom [marke]
  578. *
  579. \**************************************************************************/
  580. VOID
  581. vConvertAndSaveBGRATo4(
  582. PBYTE pDst,
  583. PULONG pulSrc,
  584. LONG cx,
  585. LONG DstX,
  586. PVOID pvpalInfo,
  587. PBYTE pWriteMask
  588. )
  589. {
  590. PPALINFO ppalInfo = (PPALINFO)pvpalInfo;
  591. PBYTE pjDst = pDst + (DstX >> 1);
  592. LONG iDst = DstX & 1;
  593. if (cx == 0)
  594. {
  595. return;
  596. }
  597. //
  598. // unaligned byte
  599. //
  600. if (iDst)
  601. {
  602. BYTE DstByte = *pjDst;
  603. ALPHAPIX pixIn;
  604. pixIn.ul = *pulSrc;
  605. PALETTE_MATCH(pixIn,ppalInfo);
  606. DstByte = (DstByte & 0xf0) | (BYTE)pixIn.ul;
  607. *pjDst = DstByte;
  608. pjDst++;
  609. pulSrc++;
  610. cx--;
  611. }
  612. //
  613. // aligned whole bytes
  614. //
  615. while (cx >= 2)
  616. {
  617. BYTE DstByte;
  618. ALPHAPIX pixIn;
  619. pixIn.ul = *pulSrc;
  620. PALETTE_MATCH(pixIn,ppalInfo);
  621. DstByte = (BYTE)(pixIn.ul << 4);
  622. pixIn.ul = *(pulSrc+1);
  623. PALETTE_MATCH(pixIn,ppalInfo);
  624. DstByte |= (BYTE)(pixIn.ul);
  625. *pjDst = DstByte;
  626. pjDst++;
  627. pulSrc += 2;
  628. cx -= 2;
  629. }
  630. //
  631. // unaligned end
  632. //
  633. if (cx)
  634. {
  635. BYTE DstByte = *pjDst;
  636. ALPHAPIX pixIn;
  637. pixIn.ul = *pulSrc;
  638. PALETTE_MATCH(pixIn,ppalInfo);
  639. DstByte = (DstByte & 0x0f) | (BYTE)(pixIn.ul << 4);
  640. *pjDst = DstByte;
  641. }
  642. }
  643. /**************************************************************************\
  644. * vConvertAndSaveBGRATo8
  645. *
  646. *
  647. * Arguments:
  648. *
  649. *
  650. *
  651. * Return Value:
  652. *
  653. *
  654. *
  655. * History:
  656. *
  657. * 1/22/1997 Mark Enstrom [marke]
  658. *
  659. \**************************************************************************/
  660. VOID
  661. vConvertAndSaveBGRATo8(
  662. PBYTE pDst,
  663. PULONG pulSrc,
  664. LONG cx,
  665. LONG DstX,
  666. PVOID pvpalInfo,
  667. PBYTE pWriteMask
  668. )
  669. {
  670. PPALINFO ppalInfo = (PPALINFO)pvpalInfo;
  671. PBYTE pjDst = (PBYTE)pDst + DstX;
  672. PBYTE pjEnd = pjDst + cx;
  673. while (pjDst != pjEnd)
  674. {
  675. ALPHAPIX pixIn;
  676. if (*pWriteMask)
  677. {
  678. pixIn.ul = *pulSrc;
  679. PALETTE_MATCH(pixIn,ppalInfo);
  680. *pjDst = (BYTE)pixIn.ul;
  681. }
  682. pWriteMask++;
  683. pulSrc++;
  684. pjDst++;
  685. }
  686. }
  687. /**************************************************************************\
  688. * vConvertAndSaveBGRAToRGB16_565
  689. *
  690. *
  691. * Arguments:
  692. *
  693. *
  694. *
  695. * Return Value:
  696. *
  697. *
  698. *
  699. * History:
  700. *
  701. * 1/22/1997 Mark Enstrom [marke]
  702. *
  703. \**************************************************************************/
  704. VOID
  705. vConvertAndSaveBGRAToRGB16_565(
  706. PBYTE pjDst,
  707. PULONG pulSrc,
  708. LONG cx,
  709. LONG DstX,
  710. PVOID ppalInfo,
  711. PBYTE pWriteMask
  712. )
  713. {
  714. PUSHORT pusDst = (PUSHORT)pjDst + DstX;
  715. PUSHORT pusEnd = pusDst + cx;
  716. while (pusDst != pusEnd)
  717. {
  718. ALPHAPIX pixIn;
  719. ALPHAPIX pixOut;
  720. pixIn.ul = *pulSrc;
  721. pixOut.ul = ((pixIn.pix.r & 0xf8) << 8) |
  722. ((pixIn.pix.g & 0xfc) << 3) |
  723. ((pixIn.pix.b & 0xf8) >> 3);
  724. *pusDst = (USHORT)pixOut.ul;
  725. pulSrc++;
  726. pusDst++;
  727. }
  728. }
  729. /**************************************************************************\
  730. * vConvertAndSaveBGRAToRGB16_555
  731. *
  732. *
  733. * Arguments:
  734. *
  735. *
  736. *
  737. * Return Value:
  738. *
  739. *
  740. *
  741. * History:
  742. *
  743. * 1/22/1997 Mark Enstrom [marke]
  744. *
  745. \**************************************************************************/
  746. VOID
  747. vConvertAndSaveBGRAToRGB16_555(
  748. PBYTE pjDst,
  749. PULONG pulSrc,
  750. LONG cx,
  751. LONG DstX,
  752. PVOID ppalInfo,
  753. PBYTE pWriteMask
  754. )
  755. {
  756. PUSHORT pusDst = (PUSHORT)pjDst + DstX;
  757. PUSHORT pusEnd = pusDst + cx;
  758. while (pusDst != pusEnd)
  759. {
  760. ALPHAPIX pixIn;
  761. ALPHAPIX pixOut;
  762. pixIn.ul = *pulSrc;
  763. pixOut.ul = ((pixIn.pix.r & 0xf8) << 7) |
  764. ((pixIn.pix.g & 0xf8) << 2) |
  765. ((pixIn.pix.b & 0xf8) >> 3);
  766. *pusDst = (USHORT)pixOut.ul;
  767. pulSrc++;
  768. pusDst++;
  769. }
  770. }
  771. /**************************************************************************\
  772. * vConvertAndSaveBGRATo16Bitfields
  773. *
  774. *
  775. * Arguments:
  776. *
  777. *
  778. *
  779. * Return Value:
  780. *
  781. *
  782. *
  783. * History:
  784. *
  785. * 1/22/1997 Mark Enstrom [marke]
  786. *
  787. \**************************************************************************/
  788. VOID
  789. vConvertAndSaveBGRATo16Bitfields(
  790. PBYTE pjDst,
  791. PULONG pulSrc,
  792. LONG cx,
  793. LONG DstX,
  794. PVOID ppalInfo,
  795. PBYTE pWriteMask
  796. )
  797. {
  798. PUSHORT pusDst = (PUSHORT)pjDst + DstX;
  799. PUSHORT pusEnd = pusDst + cx;
  800. while (pusDst != pusEnd)
  801. {
  802. ALPHAPIX pixIn;
  803. ALPHAPIX pixOut;
  804. pixIn.ul = *pulSrc;
  805. pixOut.ul = pixIn.ul; // !!!
  806. *pusDst = (USHORT)pixOut.ul;
  807. pulSrc++;
  808. pusDst++;
  809. }
  810. }
  811. /**************************************************************************\
  812. * vConvertAndSaveBGRAToRGB24
  813. *
  814. *
  815. * Arguments:
  816. *
  817. *
  818. *
  819. * Return Value:
  820. *
  821. *
  822. *
  823. * History:
  824. *
  825. * 1/22/1997 Mark Enstrom [marke]
  826. *
  827. \**************************************************************************/
  828. VOID
  829. vConvertAndSaveBGRAToRGB24(
  830. PBYTE pDst,
  831. PULONG pulSrc,
  832. LONG cx,
  833. LONG DstX,
  834. PVOID ppalInfo,
  835. PBYTE pWriteMask
  836. )
  837. {
  838. PBYTE pjDst = (PBYTE)pDst + (3 * DstX);
  839. PBYTE pjEnd = pjDst + (3 * cx);
  840. while (pjDst != pjEnd)
  841. {
  842. ALPHAPIX pixIn;
  843. pixIn.ul = *pulSrc;
  844. *pjDst = pixIn.pix.b;
  845. *(pjDst+1) = pixIn.pix.g;
  846. *(pjDst+2) = pixIn.pix.r;
  847. pulSrc++;
  848. pjDst+=3;
  849. }
  850. }
  851. /**************************************************************************\
  852. * vConvertAndSaveBGRATo32Bitfields
  853. *
  854. *
  855. * Arguments:
  856. *
  857. *
  858. *
  859. * Return Value:
  860. *
  861. *
  862. *
  863. * History:
  864. *
  865. * 1/22/1997 Mark Enstrom [marke]
  866. *
  867. \**************************************************************************/
  868. VOID
  869. vConvertAndSaveBGRATo32Bitfields(
  870. PBYTE pjDst,
  871. PULONG pulSrc,
  872. LONG cx,
  873. LONG DstX,
  874. PVOID ppalInfo,
  875. PBYTE pWriteMask
  876. )
  877. {
  878. PULONG pulDst = (PULONG)pjDst + DstX;
  879. PULONG pulEnd = pulDst + cx;
  880. while (pulDst != pulEnd)
  881. {
  882. ALPHAPIX pixIn;
  883. ALPHAPIX pixOut;
  884. pixIn.ul = *pulSrc;
  885. pixOut.ul = pixIn.ul; // !!!
  886. *pulDst = pixOut.ul;
  887. pulSrc++;
  888. pulDst++;
  889. }
  890. }
  891. /**************************************************************************\
  892. * vConvertAndSaveBGRAToRGB32
  893. *
  894. *
  895. * Arguments:
  896. *
  897. *
  898. *
  899. * Return Value:
  900. *
  901. *
  902. *
  903. * History:
  904. *
  905. * 1/22/1997 Mark Enstrom [marke]
  906. *
  907. \**************************************************************************/
  908. VOID
  909. vConvertAndSaveBGRAToRGB32(
  910. PBYTE pjDst,
  911. PULONG pulSrc,
  912. LONG cx,
  913. LONG DstX,
  914. PVOID ppalInfo,
  915. PBYTE pWriteMask
  916. )
  917. {
  918. PULONG pulDst = (PULONG)pjDst + DstX;
  919. PULONG pulEnd = pulDst + cx;
  920. while (pulDst != pulEnd)
  921. {
  922. ALPHAPIX pixIn;
  923. ALPHAPIX pixOut;
  924. pixIn.ul = *pulSrc;
  925. pixOut.pix.r = pixIn.pix.b;
  926. pixOut.pix.g = pixIn.pix.g;
  927. pixOut.pix.b = pixIn.pix.r;
  928. pixOut.pix.a = 0;
  929. *pulDst = pixOut.ul;
  930. pulSrc++;
  931. pulDst++;
  932. }
  933. }
  934. #endif