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.

952 lines
28 KiB

  1. #include "precomp.hxx"
  2. void Blt16to16_NoBlend_NoTrans_Hcopy_SRCCOPY_Vcopy(
  3. WORD* pwSrcScanLine,
  4. int iSrcScanStride,
  5. WORD* pwDstScanLine,
  6. int iDstScanStride,
  7. int iNumDstCols,
  8. int iNumDstRows)
  9. {
  10. WORD *pwSrcPixel,
  11. *pwDstPixel,
  12. *pwEndDstPixel,
  13. *pwEndDstScanLine;
  14. // set up pointer to next dst scanline beyond last
  15. pwEndDstScanLine = pwDstScanLine + iNumDstRows * iDstScanStride;
  16. while (pwDstScanLine != pwEndDstScanLine) {
  17. // set up pointers to the first pixels
  18. // on src and dst scanlines, and next
  19. // pixel after last on dst scanline
  20. pwSrcPixel = pwSrcScanLine;
  21. pwDstPixel = pwDstScanLine;
  22. pwEndDstPixel = pwDstPixel + iNumDstCols;
  23. // copy scanline one pixel at a time
  24. while (pwDstPixel != pwEndDstPixel) {
  25. *pwDstPixel++ = *pwSrcPixel++;
  26. }
  27. // advance to next scanline
  28. pwSrcScanLine += iSrcScanStride;
  29. pwDstScanLine += iDstScanStride;
  30. }
  31. }
  32. void Blt16to16_NoBlend_NoTrans_Hcopy_SRCCOPY_NoVcopy(
  33. WORD* pwSrcScanLine,
  34. int iSrcScanStride,
  35. int iNumSrcRows,
  36. WORD* pwDstScanLine,
  37. int iDstScanStride,
  38. int iNumDstCols,
  39. int iNumDstRows)
  40. {
  41. WORD *pwSrcPixel,
  42. *pwDstPixel,
  43. *pwEndDstPixel;
  44. int iVertError = 0,
  45. iVertAdvanceError,
  46. iSrcScanAdvance;
  47. // compute advance and error terms for stepping
  48. // vertically through the src bitmap
  49. if (iNumSrcRows < iNumDstRows) {
  50. iSrcScanAdvance = 0;
  51. iVertAdvanceError = iNumSrcRows;
  52. } else {
  53. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  54. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  55. }
  56. for (int i = 0; i < iNumDstRows; i++) {
  57. // set up pointers to first pixels on src and dst
  58. // scanlines, and next pixel after last on dst
  59. pwSrcPixel = pwSrcScanLine;
  60. pwDstPixel = pwDstScanLine;
  61. pwEndDstPixel = pwDstPixel + iNumDstCols;
  62. // copy scanline one pixel at a time
  63. while (pwDstPixel != pwEndDstPixel) {
  64. *pwDstPixel++ = *pwSrcPixel++;
  65. }
  66. // advance to next scanline
  67. pwSrcScanLine += iSrcScanAdvance;
  68. pwDstScanLine += iDstScanStride;
  69. // update and check vertical stepping error,
  70. // adjust src scanline pointer if necessary
  71. iVertError += iVertAdvanceError;
  72. if (iVertError >= iNumDstRows) {
  73. pwSrcScanLine += iSrcScanStride;
  74. iVertError -= iNumDstRows;
  75. }
  76. }
  77. }
  78. void Blt16to16_NoBlend_NoTrans_NoHcopy_SRCCOPY(
  79. WORD* pwSrcScanLine,
  80. int iSrcScanStride,
  81. int iNumSrcCols,
  82. int iNumSrcRows,
  83. WORD* pwDstScanLine,
  84. int iDstScanStride,
  85. int iNumDstCols,
  86. int iNumDstRows,
  87. int iHorizMirror)
  88. {
  89. WORD *pwSrcPixel,
  90. *pwDstPixel;
  91. int iVertError = 0,
  92. iVertAdvanceError,
  93. iSrcScanAdvance,
  94. iHorizError,
  95. iHorizAdvanceError,
  96. iSrcPixelAdvance;
  97. // compute advance and error terms for stepping
  98. // vertically through the src bitmap
  99. if (iNumSrcRows < iNumDstRows) {
  100. iSrcScanAdvance = 0;
  101. iVertAdvanceError = iNumSrcRows;
  102. } else {
  103. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  104. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  105. }
  106. // compute advance and error terms for stepping
  107. // horizontally through src bitmap
  108. if (iNumSrcCols < iNumDstCols) {
  109. iSrcPixelAdvance = 0;
  110. iHorizAdvanceError = iNumSrcCols;
  111. } else {
  112. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  113. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  114. }
  115. for (int i = 0; i < iNumDstRows; i++) {
  116. // set pointers to the beginning of src and dst scanlines,
  117. // clear horizontal stepping error accumulator
  118. pwSrcPixel = pwSrcScanLine;
  119. pwDstPixel = pwDstScanLine;
  120. iHorizError = 0;
  121. for (int j = 0; j < iNumDstCols; j++) {
  122. // copy a pixel
  123. *pwDstPixel = *pwSrcPixel;
  124. // advance to next pixel
  125. pwSrcPixel += iSrcPixelAdvance;
  126. pwDstPixel += iHorizMirror;
  127. // update and check horizontal stepping error,
  128. // adjust src pixel pointer if necessary
  129. iHorizError += iHorizAdvanceError;
  130. if (iHorizError >= iNumDstCols) {
  131. pwSrcPixel++;
  132. iHorizError -= iNumDstCols;
  133. }
  134. }
  135. // advance to next scanline
  136. pwSrcScanLine += iSrcScanAdvance;
  137. pwDstScanLine += iDstScanStride;
  138. // update and check vertical stepping error,
  139. // adjust src scanline pointer if necessary
  140. iVertError += iVertAdvanceError;
  141. if (iVertError >= iNumDstRows) {
  142. pwSrcScanLine += iSrcScanStride;
  143. iVertError -= iNumDstRows;
  144. }
  145. }
  146. }
  147. void Blt16to16_NoBlend_Trans_Hcopy_SRCCOPY(
  148. WORD* pwSrcScanLine,
  149. int iSrcScanStride,
  150. int iNumSrcRows,
  151. WORD* pwDstScanLine,
  152. int iDstScanStride,
  153. int iNumDstCols,
  154. int iNumDstRows,
  155. WORD wTransparentColor)
  156. {
  157. WORD *pwSrcPixel,
  158. *pwDstPixel;
  159. int iVertError = 0,
  160. iVertAdvanceError,
  161. iSrcScanAdvance;
  162. // compute advance and error terms for stepping
  163. // vertically through the src bitmap
  164. if (iNumSrcRows < iNumDstRows) {
  165. iSrcScanAdvance = 0;
  166. iVertAdvanceError = iNumSrcRows;
  167. } else {
  168. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  169. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  170. }
  171. for (int i = 0; i < iNumDstRows; i++) {
  172. // set pointers to beginning of src and dest scanlines
  173. pwSrcPixel = pwSrcScanLine;
  174. pwDstPixel = pwDstScanLine;
  175. for (int j = 0; j < iNumDstCols; j++) {
  176. // only copy pixel if it's not transparent
  177. if (*pwSrcPixel != wTransparentColor) {
  178. *pwDstPixel = *pwSrcPixel;
  179. }
  180. pwSrcPixel++;
  181. pwDstPixel++;
  182. }
  183. // advance to next scanline
  184. pwSrcScanLine += iSrcScanAdvance;
  185. pwDstScanLine += iDstScanStride;
  186. // update and check vertical stepping error,
  187. // adjust src scanline pointer if necessary
  188. iVertError += iVertAdvanceError;
  189. if (iVertError >= iNumDstRows) {
  190. pwSrcScanLine += iSrcScanStride;
  191. iVertError -= iNumDstRows;
  192. }
  193. }
  194. }
  195. void Blt16to16_NoBlend_Trans_NoHcopy_SRCCOPY(
  196. WORD* pwSrcScanLine,
  197. int iSrcScanStride,
  198. int iNumSrcCols,
  199. int iNumSrcRows,
  200. WORD* pwDstScanLine,
  201. int iDstScanStride,
  202. int iNumDstCols,
  203. int iNumDstRows,
  204. int iHorizMirror,
  205. WORD wTransparentColor)
  206. {
  207. WORD *pwSrcPixel,
  208. *pwDstPixel;
  209. int iVertError = 0,
  210. iVertAdvanceError,
  211. iSrcScanAdvance,
  212. iHorizError,
  213. iHorizAdvanceError,
  214. iSrcPixelAdvance;
  215. // compute advance and error terms for stepping
  216. // vertically through the src bitmap
  217. if (iNumSrcRows < iNumDstRows) {
  218. iSrcScanAdvance = 0;
  219. iVertAdvanceError = iNumSrcRows;
  220. } else {
  221. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  222. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  223. }
  224. // compute advance and error terms for stepping
  225. // horizontally through src bitmap
  226. if (iNumSrcCols < iNumDstCols) {
  227. iSrcPixelAdvance = 0;
  228. iHorizAdvanceError = iNumSrcCols;
  229. } else {
  230. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  231. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  232. }
  233. for (int i = 0; i < iNumDstRows; i++) {
  234. // set pointers to the beginning of src and dst scanlines,
  235. // clear horizontal stepping error accumulator
  236. pwSrcPixel = pwSrcScanLine;
  237. pwDstPixel = pwDstScanLine;
  238. iHorizError = 0;
  239. for (int j = 0; j < iNumDstCols; j++) {
  240. // only copy pixel if it's not transparent
  241. if (*pwSrcPixel != wTransparentColor) {
  242. *pwDstPixel = *pwSrcPixel;
  243. }
  244. // advance to next pixel
  245. pwSrcPixel += iSrcPixelAdvance;
  246. pwDstPixel += iHorizMirror;
  247. // update and check horizontal stepping error,
  248. // adjust src pixel pointer if necessary
  249. iHorizError += iHorizAdvanceError;
  250. if (iHorizError >= iNumDstCols) {
  251. pwSrcPixel++;
  252. iHorizError -= iNumDstCols;
  253. }
  254. }
  255. // advance to next scanline
  256. pwSrcScanLine += iSrcScanAdvance;
  257. pwDstScanLine += iDstScanStride;
  258. // update and check vertical stepping error,
  259. // adjust src scanline pointer if necessary
  260. iVertError += iVertAdvanceError;
  261. if (iVertError >= iNumDstRows) {
  262. pwSrcScanLine += iSrcScanStride;
  263. iVertError -= iNumDstRows;
  264. }
  265. }
  266. }
  267. #ifndef DDRAW
  268. void Blt16to16_Blend_NoTrans_Hcopy_SRCCOPY(
  269. WORD* pwSrcScanLine,
  270. int iSrcScanStride,
  271. int iNumSrcRows,
  272. WORD* pwDstScanLine,
  273. int iDstScanStride,
  274. int iNumDstCols,
  275. int iNumDstRows,
  276. ALPHAREF arAlpha)
  277. {
  278. WORD *pwSrcPixel,
  279. *pwDstPixel,
  280. *pwEndDstPixel;
  281. int iVertError = 0,
  282. iVertAdvanceError,
  283. iSrcScanAdvance;
  284. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  285. uiAlphaComp = 256 - uiAlpha;
  286. // compute advance and error terms for stepping
  287. // vertically through the src bitmap
  288. if (iNumSrcRows < iNumDstRows) {
  289. iSrcScanAdvance = 0;
  290. iVertAdvanceError = iNumSrcRows;
  291. } else {
  292. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  293. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  294. }
  295. for (int i = 0; i < iNumDstRows; i++) {
  296. // set up pointers to first pixels on src and dst
  297. // scanlines, and next pixel after last on dst
  298. pwSrcPixel = pwSrcScanLine;
  299. pwDstPixel = pwDstScanLine;
  300. pwEndDstPixel = pwDstPixel + iNumDstCols;
  301. // copy scanline one pixel at a time
  302. while (pwDstPixel != pwEndDstPixel) {
  303. *pwDstPixel++ = BLIT_BLEND16(*pwSrcPixel,*pwDstPixel,
  304. uiAlpha,uiAlphaComp);
  305. pwSrcPixel++;
  306. }
  307. // advance to next scanline
  308. pwSrcScanLine += iSrcScanAdvance;
  309. pwDstScanLine += iDstScanStride;
  310. // update and check vertical stepping error,
  311. // adjust src scanline pointer if necessary
  312. iVertError += iVertAdvanceError;
  313. if (iVertError >= iNumDstRows) {
  314. pwSrcScanLine += iSrcScanStride;
  315. iVertError -= iNumDstRows;
  316. }
  317. }
  318. }
  319. void Blt16to16_Blend_NoTrans_NoHcopy_SRCCOPY(
  320. WORD* pwSrcScanLine,
  321. int iSrcScanStride,
  322. int iNumSrcCols,
  323. int iNumSrcRows,
  324. WORD* pwDstScanLine,
  325. int iDstScanStride,
  326. int iNumDstCols,
  327. int iNumDstRows,
  328. int iHorizMirror,
  329. ALPHAREF arAlpha)
  330. {
  331. WORD *pwSrcPixel,
  332. *pwDstPixel;
  333. int iVertError = 0,
  334. iVertAdvanceError,
  335. iSrcScanAdvance,
  336. iHorizError,
  337. iHorizAdvanceError,
  338. iSrcPixelAdvance;
  339. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  340. uiAlphaComp = 256 - uiAlpha;
  341. // compute advance and error terms for stepping
  342. // vertically through the src bitmap
  343. if (iNumSrcRows < iNumDstRows) {
  344. iSrcScanAdvance = 0;
  345. iVertAdvanceError = iNumSrcRows;
  346. } else {
  347. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  348. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  349. }
  350. // compute advance and error terms for stepping
  351. // horizontally through src bitmap
  352. if (iNumSrcCols < iNumDstCols) {
  353. iSrcPixelAdvance = 0;
  354. iHorizAdvanceError = iNumSrcCols;
  355. } else {
  356. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  357. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  358. }
  359. for (int i = 0; i < iNumDstRows; i++) {
  360. // set pointers to the beginning of src and dst scanlines,
  361. // clear horizontal stepping error accumulator
  362. pwSrcPixel = pwSrcScanLine;
  363. pwDstPixel = pwDstScanLine;
  364. iHorizError = 0;
  365. for (int j = 0; j < iNumDstCols; j++) {
  366. // copy a pixel
  367. *pwDstPixel = BLIT_BLEND16(*pwSrcPixel,*pwDstPixel,
  368. uiAlpha,uiAlphaComp);
  369. // advance to next pixel
  370. pwSrcPixel += iSrcPixelAdvance;
  371. pwDstPixel += iHorizMirror;
  372. // update and check horizontal stepping error,
  373. // adjust src pixel pointer if necessary
  374. iHorizError += iHorizAdvanceError;
  375. if (iHorizError >= iNumDstCols) {
  376. pwSrcPixel++;
  377. iHorizError -= iNumDstCols;
  378. }
  379. }
  380. // advance to next scanline
  381. pwSrcScanLine += iSrcScanAdvance;
  382. pwDstScanLine += iDstScanStride;
  383. // update and check vertical stepping error,
  384. // adjust src scanline pointer if necessary
  385. iVertError += iVertAdvanceError;
  386. if (iVertError >= iNumDstRows) {
  387. pwSrcScanLine += iSrcScanStride;
  388. iVertError -= iNumDstRows;
  389. }
  390. }
  391. }
  392. void Blt16to16_Blend_Trans_Hcopy_SRCCOPY(
  393. WORD* pwSrcScanLine,
  394. int iSrcScanStride,
  395. int iNumSrcRows,
  396. WORD* pwDstScanLine,
  397. int iDstScanStride,
  398. int iNumDstCols,
  399. int iNumDstRows,
  400. WORD wTransparentColor,
  401. ALPHAREF arAlpha)
  402. {
  403. WORD *pwSrcPixel,
  404. *pwDstPixel;
  405. int iVertError = 0,
  406. iVertAdvanceError,
  407. iSrcScanAdvance;
  408. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  409. uiAlphaComp = 256 - uiAlpha;
  410. // compute advance and error terms for stepping
  411. // vertically through the src bitmap
  412. if (iNumSrcRows < iNumDstRows) {
  413. iSrcScanAdvance = 0;
  414. iVertAdvanceError = iNumSrcRows;
  415. } else {
  416. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  417. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  418. }
  419. for (int i = 0; i < iNumDstRows; i++) {
  420. // set pointers to beginning of src and dest scanlines
  421. pwSrcPixel = pwSrcScanLine;
  422. pwDstPixel = pwDstScanLine;
  423. for (int j = 0; j < iNumDstCols; j++) {
  424. // only copy pixel if it's not transparent
  425. if (*pwSrcPixel != wTransparentColor) {
  426. *pwDstPixel = BLIT_BLEND16(*pwSrcPixel,*pwDstPixel,
  427. uiAlpha,uiAlphaComp);
  428. }
  429. pwSrcPixel++;
  430. pwDstPixel++;
  431. }
  432. // advance to next scanline
  433. pwSrcScanLine += iSrcScanAdvance;
  434. pwDstScanLine += iDstScanStride;
  435. // update and check vertical stepping error,
  436. // adjust src scanline pointer if necessary
  437. iVertError += iVertAdvanceError;
  438. if (iVertError >= iNumDstRows) {
  439. pwSrcScanLine += iSrcScanStride;
  440. iVertError -= iNumDstRows;
  441. }
  442. }
  443. }
  444. void Blt16to16_Blend_Trans_NoHcopy_SRCCOPY(
  445. WORD* pwSrcScanLine,
  446. int iSrcScanStride,
  447. int iNumSrcCols,
  448. int iNumSrcRows,
  449. WORD* pwDstScanLine,
  450. int iDstScanStride,
  451. int iNumDstCols,
  452. int iNumDstRows,
  453. int iHorizMirror,
  454. WORD wTransparentColor,
  455. ALPHAREF arAlpha)
  456. {
  457. WORD *pwSrcPixel,
  458. *pwDstPixel;
  459. int iVertError = 0,
  460. iVertAdvanceError,
  461. iSrcScanAdvance,
  462. iHorizError,
  463. iHorizAdvanceError,
  464. iSrcPixelAdvance;
  465. UINT uiAlpha = (UINT)ALPHAFROMDWORD(arAlpha),
  466. uiAlphaComp = 256 - uiAlpha;
  467. // compute advance and error terms for stepping
  468. // vertically through the src bitmap
  469. if (iNumSrcRows < iNumDstRows) {
  470. iSrcScanAdvance = 0;
  471. iVertAdvanceError = iNumSrcRows;
  472. } else {
  473. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  474. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  475. }
  476. // compute advance and error terms for stepping
  477. // horizontally through src bitmap
  478. if (iNumSrcCols < iNumDstCols) {
  479. iSrcPixelAdvance = 0;
  480. iHorizAdvanceError = iNumSrcCols;
  481. } else {
  482. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  483. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  484. }
  485. for (int i = 0; i < iNumDstRows; i++) {
  486. // set pointers to the beginning of src and dst scanlines,
  487. // clear horizontal stepping error accumulator
  488. pwSrcPixel = pwSrcScanLine;
  489. pwDstPixel = pwDstScanLine;
  490. iHorizError = 0;
  491. for (int j = 0; j < iNumDstCols; j++) {
  492. // only copy pixel if it's not transparent
  493. if (*pwSrcPixel != wTransparentColor) {
  494. *pwDstPixel = BLIT_BLEND16(*pwSrcPixel,*pwDstPixel,
  495. uiAlpha,uiAlphaComp);
  496. }
  497. // advance to next pixel
  498. pwSrcPixel += iSrcPixelAdvance;
  499. pwDstPixel += iHorizMirror;
  500. // update and check horizontal stepping error,
  501. // adjust src pixel pointer if necessary
  502. iHorizError += iHorizAdvanceError;
  503. if (iHorizError >= iNumDstCols) {
  504. pwSrcPixel++;
  505. iHorizError -= iNumDstCols;
  506. }
  507. }
  508. // advance to next scanline
  509. pwSrcScanLine += iSrcScanAdvance;
  510. pwDstScanLine += iDstScanStride;
  511. // update and check vertical stepping error,
  512. // adjust src scanline pointer if necessary
  513. iVertError += iVertAdvanceError;
  514. if (iVertError >= iNumDstRows) {
  515. pwSrcScanLine += iSrcScanStride;
  516. iVertError -= iNumDstRows;
  517. }
  518. }
  519. }
  520. #endif
  521. //
  522. // The following blits are included with the 16bpp blits because they are
  523. // entensions of them. The only difference between these blits and the
  524. // regular 16bpp blits is that these blits only use an 8bpp palette index
  525. // for the transparent color. The rest of the blit is exactly the same.
  526. //
  527. void Blt08Ato08A_NoBlend_Trans_Hcopy_SRCCOPY(
  528. WORD* pwSrcScanLine,
  529. int iSrcScanStride,
  530. int iNumSrcRows,
  531. WORD* pwDstScanLine,
  532. int iDstScanStride,
  533. int iNumDstCols,
  534. int iNumDstRows,
  535. BYTE bTransparentColor)
  536. {
  537. WORD *pwSrcPixel,
  538. *pwDstPixel;
  539. int iVertError = 0,
  540. iVertAdvanceError,
  541. iSrcScanAdvance;
  542. // compute advance and error terms for stepping
  543. // vertically through the src bitmap
  544. if (iNumSrcRows < iNumDstRows) {
  545. iSrcScanAdvance = 0;
  546. iVertAdvanceError = iNumSrcRows;
  547. } else {
  548. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  549. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  550. }
  551. for (int i = 0; i < iNumDstRows; i++) {
  552. // set pointers to beginning of src and dest scanlines
  553. pwSrcPixel = pwSrcScanLine;
  554. pwDstPixel = pwDstScanLine;
  555. for (int j = 0; j < iNumDstCols; j++) {
  556. // only copy pixel if it's not transparent
  557. if ((BYTE)*pwSrcPixel != bTransparentColor) {
  558. *pwDstPixel = *pwSrcPixel;
  559. }
  560. pwSrcPixel++;
  561. pwDstPixel++;
  562. }
  563. // advance to next scanline
  564. pwSrcScanLine += iSrcScanAdvance;
  565. pwDstScanLine += iDstScanStride;
  566. // update and check vertical stepping error,
  567. // adjust src scanline pointer if necessary
  568. iVertError += iVertAdvanceError;
  569. if (iVertError >= iNumDstRows) {
  570. pwSrcScanLine += iSrcScanStride;
  571. iVertError -= iNumDstRows;
  572. }
  573. }
  574. }
  575. void Blt08Ato08A_NoBlend_Trans_NoHcopy_SRCCOPY(
  576. WORD* pwSrcScanLine,
  577. int iSrcScanStride,
  578. int iNumSrcCols,
  579. int iNumSrcRows,
  580. WORD* pwDstScanLine,
  581. int iDstScanStride,
  582. int iNumDstCols,
  583. int iNumDstRows,
  584. int iHorizMirror,
  585. BYTE bTransparentColor)
  586. {
  587. WORD *pwSrcPixel,
  588. *pwDstPixel;
  589. int iVertError = 0,
  590. iVertAdvanceError,
  591. iSrcScanAdvance,
  592. iHorizError,
  593. iHorizAdvanceError,
  594. iSrcPixelAdvance;
  595. // compute advance and error terms for stepping
  596. // vertically through the src bitmap
  597. if (iNumSrcRows < iNumDstRows) {
  598. iSrcScanAdvance = 0;
  599. iVertAdvanceError = iNumSrcRows;
  600. } else {
  601. iSrcScanAdvance = iSrcScanStride * (iNumSrcRows / iNumDstRows);
  602. iVertAdvanceError = iNumSrcRows % iNumDstRows;
  603. }
  604. // compute advance and error terms for stepping
  605. // horizontally through src bitmap
  606. if (iNumSrcCols < iNumDstCols) {
  607. iSrcPixelAdvance = 0;
  608. iHorizAdvanceError = iNumSrcCols;
  609. } else {
  610. iSrcPixelAdvance = iNumSrcCols / iNumDstCols;
  611. iHorizAdvanceError = iNumSrcCols % iNumDstCols;
  612. }
  613. for (int i = 0; i < iNumDstRows; i++) {
  614. // set pointers to the beginning of src and dst scanlines,
  615. // clear horizontal stepping error accumulator
  616. pwSrcPixel = pwSrcScanLine;
  617. pwDstPixel = pwDstScanLine;
  618. iHorizError = 0;
  619. for (int j = 0; j < iNumDstCols; j++) {
  620. // only copy pixel if it's not transparent
  621. if ((BYTE)*pwSrcPixel != bTransparentColor) {
  622. *pwDstPixel = *pwSrcPixel;
  623. }
  624. // advance to next pixel
  625. pwSrcPixel += iSrcPixelAdvance;
  626. pwDstPixel += iHorizMirror;
  627. // update and check horizontal stepping error,
  628. // adjust src pixel pointer if necessary
  629. iHorizError += iHorizAdvanceError;
  630. if (iHorizError >= iNumDstCols) {
  631. pwSrcPixel++;
  632. iHorizError -= iNumDstCols;
  633. }
  634. }
  635. // advance to next scanline
  636. pwSrcScanLine += iSrcScanAdvance;
  637. pwDstScanLine += iDstScanStride;
  638. // update and check vertical stepping error,
  639. // adjust src scanline pointer if necessary
  640. iVertError += iVertAdvanceError;
  641. if (iVertError >= iNumDstRows) {
  642. pwSrcScanLine += iSrcScanStride;
  643. iVertError -= iNumDstRows;
  644. }
  645. }
  646. }
  647. ///////////////////////////////////////////////////////////////////////
  648. //
  649. // Private Blt16to16_LeftToRight_BottomToTop_SRCOPY -
  650. // BitBlit from source bitmap to destination bitmap (where these
  651. // bitmaps overlap) by walking both the source and destination
  652. // from left to right and bottom to top
  653. //
  654. // Parameters:
  655. // pSrcScanLine Pointer to the first Source scan line
  656. // iSrcScanStride The Source scan stride
  657. // pDstScanLine Pointer to the first Destination scan line
  658. // iDstScanStride The Destination scan stride
  659. // iNumDstCols Number of destination columns
  660. // iNumDstRows Number of destination rows
  661. //
  662. // Return Value:
  663. // NO_ERROR or E_* value as specified in the .H file.
  664. //
  665. ///////////////////////////////////////////////////////////////////////
  666. void Blt16to16_LeftToRight_BottomToTop_SRCCOPY(WORD* pwSrcScanLine,
  667. int iSrcScanStride,
  668. WORD* pwDstScanLine,
  669. int iDstScanStride,
  670. int iNumDstCols,
  671. int iNumDstRows)
  672. {
  673. WORD *pwSrcPixel,
  674. *pwDstPixel,
  675. *pwEndDstPixel;
  676. for (int i = 0; i < iNumDstRows; i++) {
  677. // set up pointers to the first pixels
  678. // on src and dst scanlines, and next
  679. // pixel after last on dst scanline
  680. pwSrcPixel = pwSrcScanLine;
  681. pwDstPixel = pwDstScanLine;
  682. pwEndDstPixel = pwDstPixel + iNumDstCols;
  683. // copy scanline one pixel at a time
  684. while (pwDstPixel != pwEndDstPixel) {
  685. *pwDstPixel++ = *pwSrcPixel++;
  686. }
  687. // advance to next scanline
  688. pwSrcScanLine -= iSrcScanStride;
  689. pwDstScanLine -= iDstScanStride;
  690. }
  691. }
  692. ///////////////////////////////////////////////////////////////////////
  693. //
  694. // Private Blt16to16_RightToLeft_TopToBottom_SRCOPY -
  695. // BitBlit from source bitmap to destination bitmap (where these
  696. // bitmaps overlap) by walking both the source and destination
  697. // from right to left and top to bottom
  698. //
  699. // Parameters:
  700. // pSrcScanLine Pointer to the first Source scan line
  701. // iSrcScanStride The Source scan stride
  702. // pDstScanLine Pointer to the first Destination scan line
  703. // iDstScanStride The Destination scan stride
  704. // iNumDstCols Number of destination columns
  705. // iNumDstRows Number of destination rows
  706. //
  707. // Return Value:
  708. // NO_ERROR or E_* value as specified in the .H file.
  709. //
  710. ///////////////////////////////////////////////////////////////////////
  711. void Blt16to16_RightToLeft_TopToBottom_SRCCOPY(WORD* pSrcScanLine,
  712. int iSrcScanStride,
  713. WORD* pDstScanLine,
  714. int iDstScanStride,
  715. int iNumDstCols,
  716. int iNumDstRows)
  717. {
  718. WORD *pSrcPixel,
  719. *pDstPixel;
  720. for (int i = 0; i < iNumDstRows; i++) {
  721. // set pointers to beginning of src and dest scanlines
  722. pSrcPixel = pSrcScanLine;
  723. pDstPixel = pDstScanLine;
  724. for (int j = 0; j < iNumDstCols; j++)
  725. *pDstPixel-- = *pSrcPixel--;
  726. // advance to next scanline
  727. pSrcScanLine += iSrcScanStride;
  728. pDstScanLine += iDstScanStride;
  729. }
  730. }
  731. ///////////////////////////////////////////////////////////////////////
  732. //
  733. // Private Blt16to16_LeftToRight_BottomToTop_Trans_SRCCOPY -
  734. // BitBlit using a transparent color index from source bitmap to
  735. // destination bitmap (where these bitmaps overlap) by walking
  736. // both the source and destination from left to right and bottom
  737. // to top
  738. //
  739. // Parameters:
  740. // pSrcScanLine Pointer to the first Source scan line
  741. // iSrcScanStride The Source scan stride
  742. // pDstScanLine Pointer to the first Destination scan line
  743. // iDstScanStride The Destination scan stride
  744. // iNumDstCols Number of destination columns
  745. // iNumDstRows Number of destination rows
  746. // bTransparentIndex Palette Index of the transparent color
  747. //
  748. // Return Value:
  749. // NO_ERROR or E_* value as specified in the .H file.
  750. //
  751. ///////////////////////////////////////////////////////////////////////
  752. void Blt16to16_LeftToRight_BottomToTop_Trans_SRCCOPY(WORD* pSrcScanLine,
  753. int iSrcScanStride,
  754. WORD* pDstScanLine,
  755. int iDstScanStride,
  756. int iNumDstCols,
  757. int iNumDstRows,
  758. WORD wTransparentIndex)
  759. {
  760. WORD *pSrcPixel,
  761. *pDstPixel;
  762. for (int i = 0; i < iNumDstRows; i++) {
  763. // set pointers to beginning of src and dest scanlines
  764. pSrcPixel = pSrcScanLine;
  765. pDstPixel = pDstScanLine;
  766. for (int j = 0; j < iNumDstCols; j++) {
  767. // only copy pixel if it's not transparent
  768. if (*pSrcPixel != wTransparentIndex) {
  769. *pDstPixel = *pSrcPixel;
  770. }
  771. pSrcPixel++;
  772. pDstPixel++;
  773. }
  774. // advance to next scanline
  775. pSrcScanLine -= iSrcScanStride;
  776. pDstScanLine -= iDstScanStride;
  777. }
  778. }
  779. ///////////////////////////////////////////////////////////////////////
  780. //
  781. // Private Blt16to16_RightToLeft_TopToBottom_Trans_SRCOPY -
  782. // BitBlit using a transparent color index from source bitmap to
  783. // destination bitmap (where these bitmaps overlap) by walking
  784. // both the source and destination from right to left and top
  785. // to bottom
  786. //
  787. // Parameters:
  788. // pSrcScanLine Pointer to the first Source scan line
  789. // iSrcScanStride The Source scan stride
  790. // pDstScanLine Pointer to the first Destination scan line
  791. // iDstScanStride The Destination scan stride
  792. // iNumDstCols Number of destination columns
  793. // iNumDstRows Number of destination rows
  794. // bTransparentIndex Palette Index of the transparent color
  795. //
  796. // Return Value:
  797. // NO_ERROR or E_* value as specified in the .H file.
  798. //
  799. ///////////////////////////////////////////////////////////////////////
  800. void Blt16to16_RightToLeft_TopToBottom_Trans_SRCCOPY(WORD* pSrcScanLine,
  801. int iSrcScanStride,
  802. WORD* pDstScanLine,
  803. int iDstScanStride,
  804. int iNumDstCols,
  805. int iNumDstRows,
  806. WORD wTransparentIndex)
  807. {
  808. WORD *pSrcPixel,
  809. *pDstPixel;
  810. for (int i = 0; i < iNumDstRows; i++) {
  811. // set pointers to beginning of src and dest scanlines
  812. pSrcPixel = pSrcScanLine;
  813. pDstPixel = pDstScanLine;
  814. for (int j = 0; j < iNumDstCols; j++) {
  815. // only copy pixel if it's not transparent
  816. if (*pSrcPixel != wTransparentIndex) {
  817. *pDstPixel = *pSrcPixel;
  818. }
  819. pSrcPixel--;
  820. pDstPixel--;
  821. }
  822. // advance to next scanline
  823. pSrcScanLine += iSrcScanStride;
  824. pDstScanLine += iDstScanStride;
  825. }
  826. }