PageRenderTime 39ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/HoHo2 C++ Source/HoHo/Graphics/Rle.cpp

http://dhoho.googlecode.com/
C++ | 2372 lines | 1994 code | 198 blank | 180 comment | 255 complexity | 98c415fbd4cb2e24fd08cb962d017f67 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. #include "stdafx.h"
  2. #include "..\Package\FilePackage.h"
  3. #include "Display.h"
  4. #include "BitmapX.h"
  5. // -------------------------------------------------------
  6. // Name: DrawRleMMX()
  7. // Describe: 绘制RLE压缩后的位图,利用MMX
  8. // -------------------------------------------------------
  9. HRESULT CDisplay::DrawRleMMX(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest)
  10. {
  11. return S_OK;
  12. }
  13. // -------------------------------------------------------
  14. // Name: CreateRLE()
  15. // Describe: 创建空白的RLE压缩位图(内容为空)
  16. // 数据还未填入之前,不可使用
  17. // nLength为16bit单位
  18. // -------------------------------------------------------
  19. CBitmapX* CDisplay::CreateRle(int nWidth, int nHeight, int nLength, int nStatus)
  20. {
  21. CBitmapX* pBitmap;
  22. pBitmap = new CBitmapX;
  23. PushBitmap(pBitmap);
  24. pBitmap->m_lStatus = nStatus;
  25. pBitmap->m_nWidth = nWidth;
  26. pBitmap->m_nHeight = nHeight;
  27. pBitmap->m_nLength = nLength;
  28. pBitmap->m_pBuffer = new PIXEL[nLength];
  29. memset( (PIXEL*)pBitmap->m_pBuffer, 0, pBitmap->m_nLength*sizeof(PIXEL));
  30. return pBitmap;
  31. }
  32. // -------------------------------------------------------
  33. // Name: CreateRleFromFile()
  34. // Describe: 从RLE文件中载入压缩位图
  35. // -------------------------------------------------------
  36. CBitmapX* CDisplay::CreateRleFromFile(char* pFileName, iFilePackage* pPackFile)
  37. {
  38. unsigned char* pBuf;
  39. CBitmapX* pBitmap;
  40. pBitmap = new CBitmapX;
  41. PushBitmap(pBitmap);
  42. pBitmap->m_lStatus = BITMAP_TYPE_RLE;
  43. if(pPackFile == NULL)
  44. {
  45. CFile fp;
  46. if(!fp.Open(pFileName, CFile::modeRead))
  47. {
  48. Failed( "文件<%s>无法打开!", pFileName );
  49. return NULL;
  50. }
  51. long lFileLength = (long)fp.GetLength();
  52. pBuf = new unsigned char[lFileLength];
  53. memset(pBuf, 0, lFileLength);
  54. fp.Read(pBuf, lFileLength);
  55. fp.Close();
  56. }
  57. else
  58. {
  59. if(!pPackFile->LocateFile(pFileName))
  60. {
  61. Failed( "文件<%s>无法从<%s>压缩包中打开!", pFileName, pPackFile->GetPackageFileName() );
  62. return NULL;
  63. }
  64. int nFileLen = pPackFile->GetFileLength();
  65. pBuf = new unsigned char[nFileLen];
  66. memset(pBuf, 0, nFileLen);
  67. pPackFile->ReadFromFile(pBuf, &nFileLen);
  68. }
  69. long* pPoint = (long*)pBuf;
  70. if(*pPoint != 0x120501) // check marker (none: 120501 marker 16bit rle format)
  71. {
  72. Failed("Read RLE Fromat Error!");
  73. SAFE_DELETE_ARRAY(pBuf);
  74. return NULL;
  75. }
  76. pPoint++;
  77. pBitmap->m_nWidth = *pPoint;
  78. pPoint++;
  79. pBitmap->m_nHeight = *pPoint;
  80. pPoint++;
  81. pBitmap->m_nLength = *pPoint;
  82. pPoint++;
  83. pBitmap->m_lStatus = *pPoint;
  84. pPoint++;
  85. // copy rle data to bitmap rle data
  86. pBitmap->m_pBuffer = new PIXEL[pBitmap->m_nLength];
  87. memcpy( (PIXEL*)pBitmap->m_pBuffer, &pBuf[20], pBitmap->m_nLength*sizeof(PIXEL));
  88. for(int i=0; i<pBitmap->m_nLength; i++)
  89. {
  90. // 错误,待修改
  91. // 原因:RLE的数据中不单单只有Pixel数据,还有标记,标记无法进行Hi2Hi()
  92. ((PIXEL*)pBitmap->m_pBuffer)[i] = Hi2Hi( ((PIXEL*)pBitmap->m_pBuffer)[i] );
  93. }
  94. SAFE_DELETE_ARRAY(pBuf);
  95. return pBitmap;
  96. }
  97. // -------------------------------------------------------
  98. // Name: CreateIndexRleFromFile()
  99. // Describe: 从RLE文件中载入压缩索引色位图
  100. // -------------------------------------------------------
  101. CBitmapX* CDisplay::CreateIndexRleFromFile(char* pFileName, iFilePackage* pPackFile)
  102. {
  103. unsigned char* pBuf;
  104. bool bIsPalette = false;
  105. CBitmapX* pBitmap;
  106. pBitmap = new CBitmapX;
  107. PushBitmap(pBitmap);
  108. pBitmap->m_lStatus = BITMAP_TYPE_INDEX_RLE;
  109. if(pPackFile == NULL)
  110. {
  111. CFile fp;
  112. if(!fp.Open(pFileName, CFile::modeRead))
  113. {
  114. Failed( "文件<%s>无法打开!", pFileName );
  115. return NULL;
  116. }
  117. long lFileLength = (long)fp.GetLength();
  118. pBuf = new unsigned char[lFileLength];
  119. memset(pBuf, 0, lFileLength);
  120. fp.Read(pBuf, lFileLength);
  121. fp.Close();
  122. }
  123. else
  124. {
  125. if(!pPackFile->LocateFile(pFileName))
  126. {
  127. Failed( "文件<%s>无法从<%s>压缩包中打开!", pFileName, pPackFile->GetPackageFileName() );
  128. return NULL;
  129. }
  130. int nFileLen = pPackFile->GetFileLength();
  131. pBuf = new unsigned char[nFileLen];
  132. memset(pBuf, 0, nFileLen);
  133. pPackFile->ReadFromFile(pBuf, &nFileLen);
  134. }
  135. long* pPoint = (long*)pBuf;
  136. if(*pPoint != 0x120502) // check marker (none: 120501 marker 16bit rle format)
  137. {
  138. Failed("Read RLE Fromat Error!");
  139. SAFE_DELETE_ARRAY(pBuf);
  140. return NULL;
  141. }
  142. pPoint++;
  143. pBitmap->m_nWidth = *pPoint;
  144. pPoint++;
  145. pBitmap->m_nHeight = *pPoint;
  146. pPoint++;
  147. pBitmap->m_nLength = *pPoint;
  148. pPoint++;
  149. pBitmap->m_lStatus = *pPoint;
  150. pPoint++;
  151. // 载入调色板
  152. if( *pPoint == 1 )
  153. {
  154. bIsPalette = true;
  155. pPoint++;
  156. pBitmap->m_pPalette = new stPalette;
  157. PushPalette( pBitmap->m_pPalette );
  158. pBitmap->m_pPalette->lColorCount = *pPoint;
  159. PIXEL* pPaletteSrc = (PIXEL*)pBuf;
  160. pPaletteSrc += 14;
  161. for(int i=0; i<pBitmap->m_pPalette->lColorCount; i++)
  162. {
  163. pBitmap->m_pPalette->Table[i] = Hi2Hi( *pPaletteSrc );
  164. pPaletteSrc++;
  165. }
  166. }
  167. // copy rle data to bitmap rle data
  168. pBitmap->m_pBuffer = new BYTE[pBitmap->m_nLength];
  169. if( bIsPalette )
  170. memcpy( (BYTE*)pBitmap->m_pBuffer, &pBuf[28 + pBitmap->m_pPalette->lColorCount*sizeof(PIXEL)], pBitmap->m_nLength*sizeof(BYTE));
  171. else
  172. memcpy( (BYTE*)pBitmap->m_pBuffer, &pBuf[28], pBitmap->m_nLength*sizeof(BYTE));
  173. SAFE_DELETE_ARRAY(pBuf);
  174. return pBitmap;
  175. }
  176. // -------------------------------------------------------
  177. // Name: DrawRle()
  178. // Describe: 绘制RLE压缩后的位图
  179. // -------------------------------------------------------
  180. HRESULT CDisplay::DrawRle(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest)
  181. {
  182. #if _DEBUG
  183. ASSERT(pBitmapSrc);
  184. ASSERT(pBitmapSrc->m_pBuffer);
  185. ASSERT(pBitmapDest);
  186. ASSERT(pBitmapDest->m_pBuffer);
  187. #endif
  188. if(pBitmapSrc->m_lStatus == BITMAP_TYPE_RLE)
  189. {
  190. if(x < 0 || y < 0 ||
  191. (x+pBitmapSrc->m_nWidth) > pBitmapDest->m_nWidth ||
  192. (y+pBitmapSrc->m_nHeight) > pBitmapDest->m_nHeight)
  193. return DrawRleReduce(x, y, pBitmapSrc, pBitmapDest);
  194. return DrawRleFast(x, y, pBitmapSrc, pBitmapDest);
  195. }
  196. else
  197. {
  198. if(x < 0 || y < 0 ||
  199. (x+pBitmapSrc->m_nWidth) > pBitmapDest->m_nWidth ||
  200. (y+pBitmapSrc->m_nHeight) > pBitmapDest->m_nHeight)
  201. return DrawRleReduceMMX(x, y, pBitmapSrc, pBitmapDest);
  202. return DrawRleFastMMX(x, y, pBitmapSrc, pBitmapDest);
  203. }
  204. return S_OK;
  205. }
  206. // -------------------------------------------------------
  207. // Name: DrawRleFast()
  208. // Describe: 绘制RLE压缩后的位图(无裁减)
  209. // -------------------------------------------------------
  210. HRESULT CDisplay::DrawRleFast(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest)
  211. {
  212. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  213. dest += x + y * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  214. PIXEL* pPixel = (PIXEL*)pBitmapSrc->m_pBuffer;
  215. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  216. for(int i=0; i<pBitmapSrc->m_nLength; i++)
  217. {
  218. switch(*p)
  219. {
  220. case BITMAP_RLE_CONTINUE: // 绘制相同的像素
  221. {
  222. pPixel++;
  223. p++;
  224. /*
  225. wmemset(dest, *pPixel, *p);
  226. dest += *p;
  227. nBitmapX += *p;
  228. */
  229. for(int j=0; j<*p; j++)
  230. {
  231. *dest = *pPixel;
  232. dest++;
  233. }
  234. pPixel++;
  235. p += 3;
  236. i++;
  237. }
  238. break;
  239. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  240. {
  241. pPixel++;
  242. p++;
  243. int l = *p;
  244. p++;
  245. /*
  246. wmemcpy(dest, pPixel, l);
  247. dest += l;
  248. pPixel += l;
  249. i += l;
  250. p += l << 1;
  251. */
  252. for(int j=0; j<l; j++)
  253. {
  254. *dest = *pPixel;
  255. dest++;
  256. pPixel++;
  257. i++;
  258. p += 2;
  259. }
  260. }
  261. break;
  262. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  263. {
  264. pPixel++;
  265. p++;
  266. dest += *p;
  267. p++;
  268. }
  269. break;
  270. case BITMAP_RLE_ENTER: // 换行
  271. {
  272. pPixel++;
  273. p += 2;
  274. dest += pBitmapDest->m_nPitchWidth - pBitmapSrc->m_nWidth;
  275. // dest += pBitmapDest->m_nPitch;
  276. }
  277. break;
  278. default:
  279. break;
  280. }
  281. }
  282. return S_OK;
  283. }
  284. // -------------------------------------------------------
  285. // Name: DrawRleReduce()
  286. // Describe: 绘制RLE压缩后的位图, K作裁&#x153;p
  287. // -------------------------------------------------------
  288. HRESULT CDisplay::DrawRleReduce(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest)
  289. {
  290. int nBitmapX, nBitmapY;
  291. bool bCutLeft = false;
  292. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  293. if(x < 0)
  294. nBitmapX = 0;
  295. else
  296. nBitmapX = x;
  297. if(y < 0)
  298. nBitmapY = 0;
  299. else
  300. nBitmapY = y;
  301. dest += nBitmapX + nBitmapY * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  302. nBitmapX = nBitmapY = 0;
  303. PIXEL* pPixel = (PIXEL*)pBitmapSrc->m_pBuffer;
  304. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  305. if((x+nBitmapX) < 0)
  306. {
  307. bCutLeft = true;
  308. }
  309. else if((x+nBitmapX) >= pBitmapDest->m_nWidth) // 起始位置已经超过右边界
  310. {
  311. return S_OK;
  312. }
  313. if(y >= pBitmapDest->m_nHeight)
  314. return S_OK;
  315. for(int i=0; i<pBitmapSrc->m_nLength; i++)
  316. {
  317. switch(*p)
  318. {
  319. case BITMAP_RLE_CONTINUE: // 绘制相同的像素
  320. {
  321. pPixel++;
  322. p++;
  323. // 横裁剪
  324. if((y+nBitmapY) < 0)
  325. {
  326. nBitmapX += *p;
  327. pPixel++;
  328. p += 3;
  329. i++;
  330. continue;
  331. }
  332. if(bCutLeft) // 需要进行左面裁减
  333. {
  334. for(int j=0; j<*p; j++)
  335. {
  336. if((x+nBitmapX) >= 0)
  337. {
  338. *dest = *pPixel;
  339. dest++;
  340. bCutLeft = false;
  341. }
  342. nBitmapX++;
  343. }
  344. }
  345. else
  346. {
  347. for(int j=0; j<*p; j++)
  348. {
  349. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  350. {
  351. *dest = *pPixel;
  352. dest++;
  353. }
  354. nBitmapX++;
  355. }
  356. }
  357. pPixel++;
  358. p += 3;
  359. i++;
  360. }
  361. break;
  362. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  363. {
  364. pPixel++;
  365. p++;
  366. // 横裁剪
  367. if((y+nBitmapY) < 0)
  368. {
  369. int l = *p;
  370. p++;
  371. nBitmapX += l;
  372. pPixel += l;
  373. i += l;
  374. p += l * 2;
  375. continue;
  376. }
  377. int l = *p;
  378. p++;
  379. if(bCutLeft) // 需要进行左面裁减
  380. {
  381. for(int j=0; j<l; j++)
  382. {
  383. if((x+nBitmapX) >= 0)
  384. {
  385. *dest = *pPixel;
  386. dest++;
  387. bCutLeft = false;
  388. }
  389. nBitmapX++;
  390. pPixel++;
  391. i++;
  392. p += 2;
  393. }
  394. }
  395. else
  396. {
  397. for(int j=0; j<l; j++)
  398. {
  399. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  400. {
  401. *dest = *pPixel;
  402. dest++;
  403. }
  404. nBitmapX++;
  405. pPixel++;
  406. i++;
  407. p += 2;
  408. }
  409. }
  410. }
  411. break;
  412. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  413. {
  414. pPixel++;
  415. p++;
  416. if((y+nBitmapY) < 0)
  417. {
  418. nBitmapX += *p;
  419. p++;
  420. continue;
  421. }
  422. if(bCutLeft) // 需要进行左面裁减
  423. {
  424. for(int i=0; i<*p; i++)
  425. {
  426. if((x+nBitmapX) >= 0)
  427. {
  428. dest++;
  429. bCutLeft = false;
  430. }
  431. nBitmapX++;
  432. }
  433. }
  434. else
  435. {
  436. for(int i=0; i<*p; i++)
  437. {
  438. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  439. {
  440. dest++;
  441. }
  442. nBitmapX++;
  443. }
  444. // dest += *p;
  445. }
  446. p++;
  447. }
  448. break;
  449. case BITMAP_RLE_ENTER: // 换行
  450. {
  451. pPixel++;
  452. p += 2;
  453. nBitmapY++;
  454. nBitmapX = 0;
  455. if((y + nBitmapY) >= pBitmapDest->m_nHeight) // 已经超过底边界
  456. return S_OK;
  457. // 实现监测是否需要进行左面裁减
  458. if((x+nBitmapX) < 0)// || (x + nBitmapX) > pBitmapDest->m_nWidth)
  459. {
  460. if((y+nBitmapY) > 0)
  461. {
  462. bCutLeft = true;
  463. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  464. dest += abs(x+nBitmapX);
  465. dest += pBitmapDest->m_nPitch;
  466. }
  467. }
  468. else if((x+pBitmapSrc->m_nWidth) >= pBitmapDest->m_nWidth) // 总宽度大于屏幕
  469. {
  470. if((y+nBitmapY) > 0)
  471. {
  472. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  473. dest += (x+pBitmapSrc->m_nWidth) - pBitmapDest->m_nWidth;
  474. dest += pBitmapDest->m_nPitch;
  475. }
  476. }
  477. else if((y+nBitmapY) <= 0)
  478. {
  479. // ;//dest -= pBitmapSrc->m_nWidth;
  480. dest += pBitmapDest->m_nPitch;
  481. }
  482. else
  483. {
  484. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  485. dest += pBitmapDest->m_nPitch;
  486. }
  487. }
  488. break;
  489. default:
  490. break;
  491. }
  492. }
  493. return S_OK;
  494. }
  495. // -------------------------------------------------------
  496. // Name: DrawRleAlpha()
  497. // Describe: 绘制RLE压缩后的位图, K作Alpha混合
  498. // -------------------------------------------------------
  499. HRESULT CDisplay::DrawRleAlpha(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, int nAlpha)
  500. {
  501. #if _DEBUG
  502. ASSERT(pBitmapSrc);
  503. ASSERT(pBitmapSrc->m_pBuffer);
  504. ASSERT(pBitmapDest);
  505. ASSERT(pBitmapDest->m_pBuffer);
  506. #endif
  507. if( pBitmapSrc->m_lStatus == BITMAP_TYPE_RLE )
  508. {
  509. if(x < 0 || y < 0 ||
  510. (x+pBitmapSrc->m_nWidth) > pBitmapDest->m_nWidth ||
  511. (y+pBitmapSrc->m_nHeight) > pBitmapDest->m_nHeight)
  512. return DrawRleAlphaReduce(x, y, pBitmapSrc, pBitmapDest, nAlpha);
  513. return DrawRleAlphaFast(x, y, pBitmapSrc, pBitmapDest, nAlpha);
  514. }
  515. else
  516. {
  517. if(x < 0 || y < 0 ||
  518. (x+pBitmapSrc->m_nWidth) > pBitmapDest->m_nWidth ||
  519. (y+pBitmapSrc->m_nHeight) > pBitmapDest->m_nHeight)
  520. return DrawRleAlphaReduceMMX(x, y, pBitmapSrc, pBitmapDest, nAlpha);
  521. return DrawRleAlphaFastMMX(x, y, pBitmapSrc, pBitmapDest, nAlpha);
  522. }
  523. return S_OK;
  524. }
  525. // -------------------------------------------------------
  526. // Name: DrawRleAlphaFast()
  527. // Describe: 绘制RLE压缩后的位图(无裁减)
  528. // -------------------------------------------------------
  529. HRESULT CDisplay::DrawRleAlphaFast(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, int nAlpha)
  530. {
  531. DWORD rgbTemp;
  532. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  533. dest += x + y * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  534. PIXEL* pPixel = (PIXEL*)pBitmapSrc->m_pBuffer;
  535. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  536. for(int i=0; i<pBitmapSrc->m_nLength; i++)
  537. {
  538. switch(*p)
  539. {
  540. case BITMAP_RLE_CONTINUE: // 绘制相同的像素
  541. {
  542. pPixel++;
  543. p++;
  544. /*
  545. wmemset(dest, *pPixel, *p);
  546. dest += *p;
  547. nBitmapX += *p;
  548. */
  549. for(int j=0; j<*p; j++)
  550. {
  551. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  552. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  553. rgbTemp = rgbTemp & m_rgbMask;
  554. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  555. dest++;
  556. }
  557. pPixel++;
  558. p += 3;
  559. i++;
  560. }
  561. break;
  562. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  563. {
  564. pPixel++;
  565. p++;
  566. int l = *p;
  567. p++;
  568. /*
  569. wmemcpy(dest, pPixel, l);
  570. dest += l;
  571. pPixel += l;
  572. i += l;
  573. p += l << 1;
  574. */
  575. for(int j=0; j<l; j++)
  576. {
  577. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  578. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  579. rgbTemp = rgbTemp & m_rgbMask;
  580. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  581. dest++;
  582. pPixel++;
  583. i++;
  584. p += 2;
  585. }
  586. }
  587. break;
  588. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  589. {
  590. pPixel++;
  591. p++;
  592. dest += *p;
  593. p++;
  594. }
  595. break;
  596. case BITMAP_RLE_ENTER: // 换行
  597. {
  598. pPixel++;
  599. p += 2;
  600. dest += pBitmapDest->m_nPitchWidth - pBitmapSrc->m_nWidth;
  601. // dest += pBitmapDest->m_nPitch;
  602. }
  603. break;
  604. default:
  605. break;
  606. }
  607. }
  608. return S_OK;
  609. }
  610. // -------------------------------------------------------
  611. // Name: DrawRleReduceAlpha()
  612. // Describe: 绘制RLE压缩后的位图, K作裁&#x153;p、Alpha混合
  613. // -------------------------------------------------------
  614. HRESULT CDisplay::DrawRleAlphaReduce(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, int nAlpha)
  615. {
  616. DWORD rgbTemp;
  617. int nBitmapX, nBitmapY;
  618. bool bCutLeft = false;
  619. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  620. if(x < 0)
  621. nBitmapX = 0;
  622. else
  623. nBitmapX = x;
  624. if(y < 0)
  625. nBitmapY = 0;
  626. else
  627. nBitmapY = y;
  628. dest += nBitmapX + nBitmapY * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  629. nBitmapX = nBitmapY = 0;
  630. PIXEL* pPixel = (PIXEL*)pBitmapSrc->m_pBuffer;
  631. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  632. if((x+nBitmapX) < 0)
  633. {
  634. bCutLeft = true;
  635. }
  636. else if((x+nBitmapX) >= pBitmapDest->m_nWidth) // 起始位置已经超过右边界
  637. {
  638. return S_OK;
  639. }
  640. if(y >= pBitmapDest->m_nHeight)
  641. return S_OK;
  642. for(int i=0; i<pBitmapSrc->m_nLength; i++)
  643. {
  644. switch(*p)
  645. {
  646. case BITMAP_RLE_CONTINUE: // 绘制相同的像素
  647. {
  648. pPixel++;
  649. p++;
  650. // 横裁剪
  651. if((y+nBitmapY) < 0)
  652. {
  653. nBitmapX += *p;
  654. pPixel++;
  655. p += 3;
  656. i++;
  657. continue;
  658. }
  659. if(bCutLeft) // 需要进行左面裁减
  660. {
  661. for(int j=0; j<*p; j++)
  662. {
  663. if((x+nBitmapX) >= 0)
  664. {
  665. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  666. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  667. rgbTemp = rgbTemp & m_rgbMask;
  668. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  669. dest++;
  670. bCutLeft = false;
  671. }
  672. nBitmapX++;
  673. }
  674. }
  675. else
  676. {
  677. for(int j=0; j<*p; j++)
  678. {
  679. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  680. {
  681. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  682. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  683. rgbTemp = rgbTemp & m_rgbMask;
  684. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  685. dest++;
  686. }
  687. nBitmapX++;
  688. }
  689. }
  690. pPixel++;
  691. p += 3;
  692. i++;
  693. }
  694. break;
  695. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  696. {
  697. pPixel++;
  698. p++;
  699. // 横裁剪
  700. if((y+nBitmapY) < 0)
  701. {
  702. int l = *p;
  703. p++;
  704. nBitmapX += l;
  705. pPixel += l;
  706. i += l;
  707. p += l * 2;
  708. continue;
  709. }
  710. int l = *p;
  711. p++;
  712. if(bCutLeft) // 需要进行左面裁减
  713. {
  714. for(int j=0; j<l; j++)
  715. {
  716. if((x+nBitmapX) >= 0)
  717. {
  718. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  719. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  720. rgbTemp = rgbTemp & m_rgbMask;
  721. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  722. dest++;
  723. bCutLeft = false;
  724. }
  725. nBitmapX++;
  726. pPixel++;
  727. i++;
  728. p += 2;
  729. }
  730. }
  731. else
  732. {
  733. for(int j=0; j<l; j++)
  734. {
  735. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  736. {
  737. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  738. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  739. rgbTemp = rgbTemp & m_rgbMask;
  740. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  741. dest++;
  742. }
  743. nBitmapX++;
  744. pPixel++;
  745. i++;
  746. p += 2;
  747. }
  748. }
  749. }
  750. break;
  751. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  752. {
  753. pPixel++;
  754. p++;
  755. if((y+nBitmapY) < 0)
  756. {
  757. nBitmapX += *p;
  758. p++;
  759. continue;
  760. }
  761. if(bCutLeft) // 需要进行左面裁减
  762. {
  763. for(int i=0; i<*p; i++)
  764. {
  765. if((x+nBitmapX) >= 0)
  766. {
  767. dest++;
  768. bCutLeft = false;
  769. }
  770. nBitmapX++;
  771. }
  772. }
  773. else
  774. {
  775. for(int i=0; i<*p; i++)
  776. {
  777. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  778. {
  779. dest++;
  780. }
  781. nBitmapX++;
  782. }
  783. // dest += *p;
  784. }
  785. p++;
  786. }
  787. break;
  788. case BITMAP_RLE_ENTER: // 换行
  789. {
  790. pPixel++;
  791. p += 2;
  792. nBitmapY++;
  793. nBitmapX = 0;
  794. if((y + nBitmapY) >= pBitmapDest->m_nHeight) // 已经超过底边界
  795. return S_OK;
  796. // 实现监测是否需要进行左面裁减
  797. if((x+nBitmapX) < 0)// || (x + nBitmapX) > pBitmapDest->m_nWidth)
  798. {
  799. if((y+nBitmapY) > 0)
  800. {
  801. bCutLeft = true;
  802. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  803. dest += abs(x+nBitmapX);
  804. dest += pBitmapDest->m_nPitch;
  805. }
  806. }
  807. else if((x+pBitmapSrc->m_nWidth) >= pBitmapDest->m_nWidth) // 总宽度大于屏幕
  808. {
  809. if((y+nBitmapY) > 0)
  810. {
  811. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  812. dest += (x+pBitmapSrc->m_nWidth) - pBitmapDest->m_nWidth;
  813. dest += pBitmapDest->m_nPitch;
  814. }
  815. }
  816. else if((y+nBitmapY) <= 0)
  817. {
  818. // ;//dest -= pBitmapSrc->m_nWidth;
  819. dest += pBitmapDest->m_nPitch;
  820. }
  821. else
  822. {
  823. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  824. dest += pBitmapDest->m_nPitch;
  825. }
  826. }
  827. break;
  828. default:
  829. break;
  830. }
  831. }
  832. return S_OK;
  833. }
  834. // -------------------------------------------------------
  835. // Name: DrawIndexRle()
  836. // Describe: 绘制RLE压缩后的索引色位图
  837. // -------------------------------------------------------
  838. HRESULT CDisplay::DrawIndexRle(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, stPalette* pPalette)
  839. {
  840. #if _DEBUG
  841. ASSERT(pBitmapSrc);
  842. ASSERT(pBitmapSrc->m_pBuffer);
  843. ASSERT(pBitmapDest);
  844. ASSERT(pBitmapDest->m_pBuffer);
  845. ASSERT(pPalette);
  846. #endif
  847. if(x < 0 || y < 0 ||
  848. (x+pBitmapSrc->m_nWidth) > pBitmapDest->m_nWidth ||
  849. (y+pBitmapSrc->m_nHeight) > pBitmapDest->m_nHeight)
  850. return DrawIndexRleReduce(x, y, pBitmapSrc, pBitmapDest, pPalette);
  851. return DrawIndexRleFast(x, y, pBitmapSrc, pBitmapDest, pPalette);
  852. }
  853. // -------------------------------------------------------
  854. // Name: DrawIndexRleFast()
  855. // Describe: 绘制RLE压缩后的索引色位图,&#x;o裁&#x153;p
  856. // -------------------------------------------------------
  857. HRESULT CDisplay::DrawIndexRleFast(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, stPalette* pPalette)
  858. {
  859. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  860. dest += x + y * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  861. BYTE* pPixel = (BYTE*)pBitmapSrc->m_pBuffer;
  862. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  863. for(int i=0; i<pBitmapSrc->m_nLength; i+=2)
  864. {
  865. switch(*p)
  866. {
  867. case BITMAP_RLE_CONTINUE: // 绘制相同的像素
  868. {
  869. pPixel += 2;
  870. p++;
  871. for(int j=0; j<*p; j++)
  872. {
  873. *dest = pPalette->Table[*pPixel];
  874. dest++;
  875. }
  876. pPixel++;
  877. p += 2;
  878. i++;
  879. }
  880. break;
  881. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  882. {
  883. pPixel += 2;
  884. p++;
  885. int l = *p;
  886. p++;
  887. for(int j=0; j<l; j++)
  888. {
  889. *dest = pPalette->Table[*pPixel];
  890. dest++;
  891. pPixel++;
  892. i++;
  893. p++;
  894. }
  895. }
  896. break;
  897. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  898. {
  899. pPixel += 2;
  900. p++;
  901. dest += *p;
  902. p++;
  903. }
  904. break;
  905. case BITMAP_RLE_ENTER: // 换行
  906. {
  907. pPixel += 2;
  908. p += 2;
  909. dest += pBitmapDest->m_nPitchWidth - pBitmapSrc->m_nWidth;
  910. }
  911. break;
  912. default:
  913. break;
  914. }
  915. }
  916. return S_OK;
  917. }
  918. // -------------------------------------------------------
  919. // Name: DrawIndexRleReduce()
  920. // Describe: 绘制RLE压缩后的索引色位图,做裁&#x153;p
  921. // -------------------------------------------------------
  922. HRESULT CDisplay::DrawIndexRleReduce(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, stPalette* pPalette)
  923. {
  924. int nBitmapX, nBitmapY;
  925. bool bCutLeft = false;
  926. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  927. if(x < 0)
  928. nBitmapX = 0;
  929. else
  930. nBitmapX = x;
  931. if(y < 0)
  932. nBitmapY = 0;
  933. else
  934. nBitmapY = y;
  935. dest += nBitmapX + nBitmapY * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  936. nBitmapX = nBitmapY = 0;
  937. BYTE* pPixel = (BYTE*)pBitmapSrc->m_pBuffer;
  938. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  939. if((x+nBitmapX) < 0)
  940. {
  941. bCutLeft = true;
  942. }
  943. else if((x+nBitmapX) >= pBitmapDest->m_nWidth) // 起始位置已经超过右边界
  944. {
  945. return S_OK;
  946. }
  947. if(y >= pBitmapDest->m_nHeight)
  948. return S_OK;
  949. for(int i=0; i<pBitmapSrc->m_nLength; i+=2)
  950. {
  951. switch(*p)
  952. {
  953. case BITMAP_RLE_CONTINUE: // 绘制相同的像素
  954. {
  955. pPixel += 2;
  956. p++;
  957. // 横裁剪
  958. if((y+nBitmapY) < 0)
  959. {
  960. nBitmapX += *p;
  961. pPixel++;
  962. p += 2;
  963. i++;
  964. continue;
  965. }
  966. if(bCutLeft) // 需要进行左面裁减
  967. {
  968. for(int j=0; j<*p; j++)
  969. {
  970. if((x+nBitmapX) >= 0)
  971. {
  972. *dest = pPalette->Table[*pPixel];
  973. dest++;
  974. bCutLeft = false;
  975. }
  976. nBitmapX++;
  977. }
  978. }
  979. else
  980. {
  981. for(int j=0; j<*p; j++)
  982. {
  983. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  984. {
  985. *dest = pPalette->Table[*pPixel];
  986. dest++;
  987. }
  988. nBitmapX++;
  989. }
  990. }
  991. pPixel++;
  992. p += 2;
  993. i++;
  994. }
  995. break;
  996. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  997. {
  998. pPixel += 2;
  999. p++;
  1000. // 横裁剪
  1001. if((y+nBitmapY) < 0)
  1002. {
  1003. int l = *p;
  1004. p++;
  1005. nBitmapX += l;
  1006. pPixel += l;
  1007. i += l;
  1008. p += l;
  1009. continue;
  1010. }
  1011. int l = *p;
  1012. p++;
  1013. if(bCutLeft) // 需要进行左面裁减
  1014. {
  1015. for(int j=0; j<l; j++)
  1016. {
  1017. if((x+nBitmapX) >= 0)
  1018. {
  1019. *dest = pPalette->Table[*pPixel];
  1020. dest++;
  1021. bCutLeft = false;
  1022. }
  1023. nBitmapX++;
  1024. pPixel++;
  1025. i++;
  1026. p++;
  1027. }
  1028. }
  1029. else
  1030. {
  1031. for(int j=0; j<l; j++)
  1032. {
  1033. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1034. {
  1035. *dest = pPalette->Table[*pPixel];
  1036. dest++;
  1037. }
  1038. nBitmapX++;
  1039. pPixel++;
  1040. i++;
  1041. p++;
  1042. }
  1043. }
  1044. }
  1045. break;
  1046. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  1047. {
  1048. pPixel += 2;
  1049. p++;
  1050. if((y+nBitmapY) < 0)
  1051. {
  1052. nBitmapX += *p;
  1053. p++;
  1054. continue;
  1055. }
  1056. if(bCutLeft) // 需要进行左面裁减
  1057. {
  1058. for(int i=0; i<*p; i++)
  1059. {
  1060. if((x+nBitmapX) >= 0)
  1061. {
  1062. dest++;
  1063. bCutLeft = false;
  1064. }
  1065. nBitmapX++;
  1066. }
  1067. }
  1068. else
  1069. {
  1070. for(int i=0; i<*p; i++)
  1071. {
  1072. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1073. {
  1074. dest++;
  1075. }
  1076. nBitmapX++;
  1077. }
  1078. // dest += *p;
  1079. }
  1080. p++;
  1081. }
  1082. break;
  1083. case BITMAP_RLE_ENTER: // 换行
  1084. {
  1085. pPixel += 2;
  1086. p += 2;
  1087. nBitmapY++;
  1088. nBitmapX = 0;
  1089. if((y + nBitmapY) >= pBitmapDest->m_nHeight) // 已经超过底边界
  1090. return S_OK;
  1091. // 实现监测是否需要进行左面裁减
  1092. if((x+nBitmapX) < 0)// || (x + nBitmapX) > pBitmapDest->m_nWidth)
  1093. {
  1094. if((y+nBitmapY) > 0)
  1095. {
  1096. bCutLeft = true;
  1097. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1098. dest += abs(x+nBitmapX);
  1099. dest += pBitmapDest->m_nPitch;
  1100. }
  1101. }
  1102. else if((x+pBitmapSrc->m_nWidth) >= pBitmapDest->m_nWidth) // 总宽度大于屏幕
  1103. {
  1104. if((y+nBitmapY) > 0)
  1105. {
  1106. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1107. dest += (x+pBitmapSrc->m_nWidth) - pBitmapDest->m_nWidth;
  1108. dest += pBitmapDest->m_nPitch;
  1109. }
  1110. }
  1111. else if((y+nBitmapY) <= 0)
  1112. {
  1113. // ;//dest -= pBitmapSrc->m_nWidth;
  1114. dest += pBitmapDest->m_nPitch;
  1115. }
  1116. else
  1117. {
  1118. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1119. dest += pBitmapDest->m_nPitch;
  1120. }
  1121. }
  1122. break;
  1123. default:
  1124. break;
  1125. }
  1126. }
  1127. return S_OK;
  1128. }
  1129. // -------------------------------------------------------
  1130. // Name: DrawIndexRleAlpha()
  1131. // Describe: 绘制RLE压缩后的索引色位图, K作Alpha混合
  1132. // -------------------------------------------------------
  1133. HRESULT CDisplay::DrawIndexRleAlpha(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, stPalette* pPalette, int nAlpha)
  1134. {
  1135. #if _DEBUG
  1136. ASSERT(pBitmapSrc);
  1137. ASSERT(pBitmapSrc->m_pBuffer);
  1138. ASSERT(pBitmapDest);
  1139. ASSERT(pBitmapDest->m_pBuffer);
  1140. ASSERT(pPalette);
  1141. #endif
  1142. if(x < 0 || y < 0 ||
  1143. (x+pBitmapSrc->m_nWidth) > pBitmapDest->m_nWidth ||
  1144. (y+pBitmapSrc->m_nHeight) > pBitmapDest->m_nHeight)
  1145. return DrawIndexRleAlphaReduce(x, y, pBitmapSrc, pBitmapDest, pPalette, nAlpha);
  1146. return DrawIndexRleAlphaFast(x, y, pBitmapSrc, pBitmapDest, pPalette, nAlpha);
  1147. }
  1148. // -------------------------------------------------------
  1149. // Name: DrawIndexRleAlphaFast()
  1150. // Describe: 绘制RLE压缩后的索引色位图,&#x;o裁&#x153;p, KAlpha
  1151. // -------------------------------------------------------
  1152. HRESULT CDisplay::DrawIndexRleAlphaFast(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, stPalette* pPalette, int nAlpha)
  1153. {
  1154. DWORD rgbTemp;
  1155. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  1156. dest += x + y * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  1157. BYTE* pPixel = (BYTE*)pBitmapSrc->m_pBuffer;
  1158. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  1159. for(int i=0; i<pBitmapSrc->m_nLength; i+=2)
  1160. {
  1161. switch(*p)
  1162. {
  1163. case BITMAP_RLE_CONTINUE: // 绘制相同的像素
  1164. {
  1165. pPixel += 2;
  1166. p++;
  1167. for(int j=0; j<*p; j++)
  1168. {
  1169. rgbTemp = ((((pPalette->Table[*pPixel]<<16)|pPalette->Table[*pPixel]) & m_rgbMask ) * nAlpha
  1170. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1171. rgbTemp = rgbTemp & m_rgbMask;
  1172. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1173. // *dest = pPalette->Table[*pPixel];
  1174. dest++;
  1175. }
  1176. pPixel++;
  1177. p += 2;
  1178. i++;
  1179. }
  1180. break;
  1181. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  1182. {
  1183. pPixel += 2;
  1184. p++;
  1185. int l = *p;
  1186. p++;
  1187. for(int j=0; j<l; j++)
  1188. {
  1189. rgbTemp = ((((pPalette->Table[*pPixel]<<16)|pPalette->Table[*pPixel]) & m_rgbMask ) * nAlpha
  1190. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1191. rgbTemp = rgbTemp & m_rgbMask;
  1192. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1193. // *dest = pPalette->Table[*pPixel];
  1194. dest++;
  1195. pPixel++;
  1196. i++;
  1197. p++;
  1198. }
  1199. }
  1200. break;
  1201. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  1202. {
  1203. pPixel += 2;
  1204. p++;
  1205. dest += *p;
  1206. p++;
  1207. }
  1208. break;
  1209. case BITMAP_RLE_ENTER: // 换行
  1210. {
  1211. pPixel += 2;
  1212. p += 2;
  1213. dest += pBitmapDest->m_nPitchWidth - pBitmapSrc->m_nWidth;
  1214. }
  1215. break;
  1216. default:
  1217. break;
  1218. }
  1219. }
  1220. return S_OK;
  1221. }
  1222. // -------------------------------------------------------
  1223. // Name: DrawIndexRleAlphaReduce()
  1224. // Describe: 绘制RLE压缩后的索引色位图,做裁&#x153;p, KAlpha
  1225. // -------------------------------------------------------
  1226. HRESULT CDisplay::DrawIndexRleAlphaReduce(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, stPalette* pPalette, int nAlpha)
  1227. {
  1228. DWORD rgbTemp;
  1229. int nBitmapX, nBitmapY;
  1230. bool bCutLeft = false;
  1231. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  1232. if(x < 0)
  1233. nBitmapX = 0;
  1234. else
  1235. nBitmapX = x;
  1236. if(y < 0)
  1237. nBitmapY = 0;
  1238. else
  1239. nBitmapY = y;
  1240. dest += nBitmapX + nBitmapY * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  1241. nBitmapX = nBitmapY = 0;
  1242. BYTE* pPixel = (BYTE*)pBitmapSrc->m_pBuffer;
  1243. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  1244. if((x+nBitmapX) < 0)
  1245. {
  1246. bCutLeft = true;
  1247. }
  1248. else if((x+nBitmapX) >= pBitmapDest->m_nWidth) // 起始位置已经超过右边界
  1249. {
  1250. return S_OK;
  1251. }
  1252. if(y >= pBitmapDest->m_nHeight)
  1253. return S_OK;
  1254. for(int i=0; i<pBitmapSrc->m_nLength; i+=2)
  1255. {
  1256. switch(*p)
  1257. {
  1258. case BITMAP_RLE_CONTINUE: // 绘制相同的像素
  1259. {
  1260. pPixel += 2;
  1261. p++;
  1262. // 横裁剪
  1263. if((y+nBitmapY) < 0)
  1264. {
  1265. nBitmapX += *p;
  1266. pPixel++;
  1267. p += 2;
  1268. i++;
  1269. continue;
  1270. }
  1271. if(bCutLeft) // 需要进行左面裁减
  1272. {
  1273. for(int j=0; j<*p; j++)
  1274. {
  1275. if((x+nBitmapX) >= 0)
  1276. {
  1277. rgbTemp = ((((pPalette->Table[*pPixel]<<16)|pPalette->Table[*pPixel]) & m_rgbMask ) * nAlpha
  1278. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1279. rgbTemp = rgbTemp & m_rgbMask;
  1280. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1281. // *dest = pPalette->Table[*pPixel];
  1282. dest++;
  1283. bCutLeft = false;
  1284. }
  1285. nBitmapX++;
  1286. }
  1287. }
  1288. else
  1289. {
  1290. for(int j=0; j<*p; j++)
  1291. {
  1292. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1293. {
  1294. rgbTemp = ((((pPalette->Table[*pPixel]<<16)|pPalette->Table[*pPixel]) & m_rgbMask ) * nAlpha
  1295. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1296. rgbTemp = rgbTemp & m_rgbMask;
  1297. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1298. // *dest = pPalette->Table[*pPixel];
  1299. dest++;
  1300. }
  1301. nBitmapX++;
  1302. }
  1303. }
  1304. pPixel++;
  1305. p += 2;
  1306. i++;
  1307. }
  1308. break;
  1309. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  1310. {
  1311. pPixel += 2;
  1312. p++;
  1313. // 横裁剪
  1314. if((y+nBitmapY) < 0)
  1315. {
  1316. int l = *p;
  1317. p++;
  1318. nBitmapX += l;
  1319. pPixel += l;
  1320. i += l;
  1321. p += l;
  1322. continue;
  1323. }
  1324. int l = *p;
  1325. p++;
  1326. if(bCutLeft) // 需要进行左面裁减
  1327. {
  1328. for(int j=0; j<l; j++)
  1329. {
  1330. if((x+nBitmapX) >= 0)
  1331. {
  1332. rgbTemp = ((((pPalette->Table[*pPixel]<<16)|pPalette->Table[*pPixel]) & m_rgbMask ) * nAlpha
  1333. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1334. rgbTemp = rgbTemp & m_rgbMask;
  1335. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1336. // *dest = pPalette->Table[*pPixel];
  1337. dest++;
  1338. bCutLeft = false;
  1339. }
  1340. nBitmapX++;
  1341. pPixel++;
  1342. i++;
  1343. p++;
  1344. }
  1345. }
  1346. else
  1347. {
  1348. for(int j=0; j<l; j++)
  1349. {
  1350. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1351. {
  1352. rgbTemp = ((((pPalette->Table[*pPixel]<<16)|pPalette->Table[*pPixel]) & m_rgbMask ) * nAlpha
  1353. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1354. rgbTemp = rgbTemp & m_rgbMask;
  1355. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1356. // *dest = pPalette->Table[*pPixel];
  1357. dest++;
  1358. }
  1359. nBitmapX++;
  1360. pPixel++;
  1361. i++;
  1362. p++;
  1363. }
  1364. }
  1365. }
  1366. break;
  1367. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  1368. {
  1369. pPixel += 2;
  1370. p++;
  1371. if((y+nBitmapY) < 0)
  1372. {
  1373. nBitmapX += *p;
  1374. p++;
  1375. continue;
  1376. }
  1377. if(bCutLeft) // 需要进行左面裁减
  1378. {
  1379. for(int i=0; i<*p; i++)
  1380. {
  1381. if((x+nBitmapX) >= 0)
  1382. {
  1383. dest++;
  1384. bCutLeft = false;
  1385. }
  1386. nBitmapX++;
  1387. }
  1388. }
  1389. else
  1390. {
  1391. for(int i=0; i<*p; i++)
  1392. {
  1393. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1394. {
  1395. dest++;
  1396. }
  1397. nBitmapX++;
  1398. }
  1399. // dest += *p;
  1400. }
  1401. p++;
  1402. }
  1403. break;
  1404. case BITMAP_RLE_ENTER: // 换行
  1405. {
  1406. pPixel += 2;
  1407. p += 2;
  1408. nBitmapY++;
  1409. nBitmapX = 0;
  1410. if((y + nBitmapY) >= pBitmapDest->m_nHeight) // 已经超过底边界
  1411. return S_OK;
  1412. // 实现监测是否需要进行左面裁减
  1413. if((x+nBitmapX) < 0)// || (x + nBitmapX) > pBitmapDest->m_nWidth)
  1414. {
  1415. if((y+nBitmapY) > 0)
  1416. {
  1417. bCutLeft = true;
  1418. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1419. dest += abs(x+nBitmapX);
  1420. dest += pBitmapDest->m_nPitch;
  1421. }
  1422. }
  1423. else if((x+pBitmapSrc->m_nWidth) >= pBitmapDest->m_nWidth) // 总宽度大于屏幕
  1424. {
  1425. if((y+nBitmapY) > 0)
  1426. {
  1427. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1428. dest += (x+pBitmapSrc->m_nWidth) - pBitmapDest->m_nWidth;
  1429. dest += pBitmapDest->m_nPitch;
  1430. }
  1431. }
  1432. else if((y+nBitmapY) <= 0)
  1433. {
  1434. // ;//dest -= pBitmapSrc->m_nWidth;
  1435. dest += pBitmapDest->m_nPitch;
  1436. }
  1437. else
  1438. {
  1439. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1440. dest += pBitmapDest->m_nPitch;
  1441. }
  1442. }
  1443. break;
  1444. default:
  1445. break;
  1446. }
  1447. }
  1448. return S_OK;
  1449. }
  1450. // --------------------------------------------------------------------------------------------------------------
  1451. //
  1452. // MMX&#x192;&#x17E;化部分:
  1453. //
  1454. // --------------------------------------------------------------------------------------------------------------
  1455. // -------------------------------------------------------
  1456. // Name: DrawRleFastMMX()
  1457. // Describe: 绘制RLE压缩后的位图(无裁减)
  1458. // -------------------------------------------------------
  1459. HRESULT CDisplay::DrawRleFastMMX(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest)
  1460. {
  1461. DWORD rgbTemp;
  1462. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  1463. dest += x + y * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  1464. PIXEL* pPixel = (PIXEL*)pBitmapSrc->m_pBuffer;
  1465. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  1466. for(int i=0; i<pBitmapSrc->m_nLength; i++)
  1467. {
  1468. switch(*p)
  1469. {
  1470. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  1471. {
  1472. pPixel++;
  1473. p++;
  1474. int l = *p;
  1475. p++;
  1476. // 特殊的处理,进行边缘的50% Alpha混合,只对标记为MMX的Rle压缩数据有效
  1477. // 如果在两个像素点以下,两像素都需要进行50%Alpha的混合
  1478. if( l <= 2 )
  1479. {
  1480. for(int j=0; j<l; j++)
  1481. {
  1482. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1483. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1484. rgbTemp = rgbTemp & m_rgbMask;
  1485. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1486. dest++;
  1487. pPixel++;
  1488. i++;
  1489. p += 2;
  1490. }
  1491. break;
  1492. }
  1493. // 通常情况,头、尾两个像素进行50%Alpha混合
  1494. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1495. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1496. rgbTemp = rgbTemp & m_rgbMask;
  1497. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1498. dest++;
  1499. pPixel++;
  1500. i++;
  1501. p += 2;
  1502. l--;
  1503. for(int j=1; j<l; j++)
  1504. {
  1505. *dest = *pPixel;
  1506. dest++;
  1507. pPixel++;
  1508. i++;
  1509. p += 2;
  1510. }
  1511. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1512. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1513. rgbTemp = rgbTemp & m_rgbMask;
  1514. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1515. dest++;
  1516. pPixel++;
  1517. i++;
  1518. p += 2;
  1519. }
  1520. break;
  1521. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  1522. {
  1523. pPixel++;
  1524. p++;
  1525. dest += *p;
  1526. p++;
  1527. }
  1528. break;
  1529. case BITMAP_RLE_ENTER: // 换行
  1530. {
  1531. pPixel++;
  1532. p += 2;
  1533. dest += pBitmapDest->m_nPitchWidth - pBitmapSrc->m_nWidth;
  1534. }
  1535. break;
  1536. default:
  1537. break;
  1538. }
  1539. }
  1540. return S_OK;
  1541. }
  1542. // -------------------------------------------------------
  1543. // Name: DrawRleReduceMMX()
  1544. // Describe: 绘制RLE压缩后的位图, K作裁&#x153;p
  1545. // -------------------------------------------------------
  1546. HRESULT CDisplay::DrawRleReduceMMX(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest)
  1547. {
  1548. DWORD rgbTemp;
  1549. int nBitmapX, nBitmapY;
  1550. bool bCutLeft = false;
  1551. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  1552. if(x < 0)
  1553. nBitmapX = 0;
  1554. else
  1555. nBitmapX = x;
  1556. if(y < 0)
  1557. nBitmapY = 0;
  1558. else
  1559. nBitmapY = y;
  1560. dest += nBitmapX + nBitmapY * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  1561. nBitmapX = nBitmapY = 0;
  1562. PIXEL* pPixel = (PIXEL*)pBitmapSrc->m_pBuffer;
  1563. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  1564. if((x+nBitmapX) < 0)
  1565. {
  1566. bCutLeft = true;
  1567. }
  1568. else if((x+nBitmapX) >= pBitmapDest->m_nWidth) // 起始位置已经超过右边界
  1569. {
  1570. return S_OK;
  1571. }
  1572. if(y >= pBitmapDest->m_nHeight)
  1573. return S_OK;
  1574. for(int i=0; i<pBitmapSrc->m_nLength; i++)
  1575. {
  1576. switch(*p)
  1577. {
  1578. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  1579. {
  1580. pPixel++;
  1581. p++;
  1582. // 横裁剪
  1583. if((y+nBitmapY) < 0)
  1584. {
  1585. int l = *p;
  1586. p++;
  1587. nBitmapX += l;
  1588. pPixel += l;
  1589. i += l;
  1590. p += l * 2;
  1591. continue;
  1592. }
  1593. int l = *p; // l 为数据长度
  1594. p++;
  1595. // 特殊的处理,进行边缘的50% Alpha混合,只对标记为MMX的Rle压缩数据有效
  1596. if(bCutLeft) // 需要进行左面裁减
  1597. {
  1598. if( l <= 2 ) // 如果小于两个像素,那就不进行边缘混合
  1599. {
  1600. for(int j=0; j<l; j++)
  1601. {
  1602. if((x+nBitmapX) >= 0)
  1603. {
  1604. /*
  1605. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1606. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1607. rgbTemp = rgbTemp & m_rgbMask;
  1608. *dest = (WORD)((rgbTemp>>16)|rgbTemp);*/
  1609. *dest = *pPixel;
  1610. dest++;
  1611. bCutLeft = false;
  1612. }
  1613. nBitmapX++;
  1614. pPixel++;
  1615. i++;
  1616. p += 2;
  1617. }
  1618. break;
  1619. }
  1620. // 通常情况,头、尾两个像素进行50%Alpha混合
  1621. if((x+nBitmapX) >= 0)
  1622. {
  1623. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1624. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1625. rgbTemp = rgbTemp & m_rgbMask;
  1626. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1627. dest++;
  1628. bCutLeft = false;
  1629. }
  1630. nBitmapX++;
  1631. pPixel++;
  1632. i++;
  1633. p += 2;
  1634. l--;
  1635. for(int j=1; j<l; j++)
  1636. {
  1637. if((x+nBitmapX) >= 0)
  1638. {
  1639. *dest = *pPixel;
  1640. dest++;
  1641. bCutLeft = false;
  1642. }
  1643. nBitmapX++;
  1644. pPixel++;
  1645. i++;
  1646. p += 2;
  1647. }
  1648. if( (x+nBitmapX) >= 0 )
  1649. {
  1650. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1651. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1652. rgbTemp = rgbTemp & m_rgbMask;
  1653. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1654. dest++;
  1655. bCutLeft = false;
  1656. }
  1657. nBitmapX++;
  1658. pPixel++;
  1659. i++;
  1660. p += 2;
  1661. }
  1662. else
  1663. {
  1664. if( l <= 2 )
  1665. {
  1666. for(int j=0; j<l; j++)
  1667. {
  1668. if(((x+nBitmapX) < pBitmapDest->m_nWidth))
  1669. {
  1670. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1671. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1672. rgbTemp = rgbTemp & m_rgbMask;
  1673. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1674. dest++;
  1675. }
  1676. nBitmapX++;
  1677. pPixel++;
  1678. i++;
  1679. p += 2;
  1680. }
  1681. break;
  1682. }
  1683. // 通常情况,头、尾两个像素进行50%Alpha混合
  1684. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1685. {
  1686. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1687. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1688. rgbTemp = rgbTemp & m_rgbMask;
  1689. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1690. dest++;
  1691. }
  1692. nBitmapX++;
  1693. pPixel++;
  1694. i++;
  1695. p += 2;
  1696. l--;
  1697. for(int j=1; j<l; j++)
  1698. {
  1699. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1700. {
  1701. *dest = *pPixel;
  1702. dest++;
  1703. }
  1704. nBitmapX++;
  1705. pPixel++;
  1706. i++;
  1707. p += 2;
  1708. }
  1709. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1710. {
  1711. rgbTemp = ( ((((*pPixel<<16)|*pPixel) & m_rgbMask ) << 4)
  1712. + ((((*dest<<16)|*dest) & m_rgbMask ) << 4 ) ) >> 5;
  1713. rgbTemp = rgbTemp & m_rgbMask;
  1714. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1715. dest++;
  1716. }
  1717. nBitmapX++;
  1718. pPixel++;
  1719. i++;
  1720. p += 2;
  1721. }
  1722. }
  1723. break;
  1724. case BITMAP_RLE_COLORKEY: // 跳过ColorKey
  1725. {
  1726. pPixel++;
  1727. p++;
  1728. if((y+nBitmapY) < 0)
  1729. {
  1730. nBitmapX += *p;
  1731. p++;
  1732. continue;
  1733. }
  1734. if(bCutLeft) // 需要进行左面裁减
  1735. {
  1736. for(int i=0; i<*p; i++)
  1737. {
  1738. if((x+nBitmapX) >= 0)
  1739. {
  1740. dest++;
  1741. bCutLeft = false;
  1742. }
  1743. nBitmapX++;
  1744. }
  1745. }
  1746. else
  1747. {
  1748. for(int i=0; i<*p; i++)
  1749. {
  1750. if((x+nBitmapX) < pBitmapDest->m_nWidth)
  1751. {
  1752. dest++;
  1753. }
  1754. nBitmapX++;
  1755. }
  1756. }
  1757. p++;
  1758. }
  1759. break;
  1760. case BITMAP_RLE_ENTER: // 换行
  1761. {
  1762. pPixel++;
  1763. p += 2;
  1764. nBitmapY++;
  1765. nBitmapX = 0;
  1766. if((y + nBitmapY) >= pBitmapDest->m_nHeight) // 已经超过底边界
  1767. return S_OK;
  1768. // 实现监测是否需要进行左面裁减
  1769. if((x+nBitmapX) < 0)// || (x + nBitmapX) > pBitmapDest->m_nWidth)
  1770. {
  1771. if((y+nBitmapY) > 0)
  1772. {
  1773. bCutLeft = true;
  1774. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1775. dest += abs(x+nBitmapX);
  1776. dest += pBitmapDest->m_nPitch;
  1777. }
  1778. }
  1779. else if((x+pBitmapSrc->m_nWidth) >= pBitmapDest->m_nWidth) // 总宽度大于屏幕
  1780. {
  1781. if((y+nBitmapY) > 0)
  1782. {
  1783. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1784. dest += (x+pBitmapSrc->m_nWidth) - pBitmapDest->m_nWidth;
  1785. dest += pBitmapDest->m_nPitch;
  1786. }
  1787. }
  1788. else if((y+nBitmapY) <= 0)
  1789. {
  1790. dest += pBitmapDest->m_nPitch;
  1791. }
  1792. else
  1793. {
  1794. dest += pBitmapDest->m_nWidth - pBitmapSrc->m_nWidth;
  1795. dest += pBitmapDest->m_nPitch;
  1796. }
  1797. }
  1798. break;
  1799. default:
  1800. break;
  1801. }
  1802. }
  1803. return S_OK;
  1804. }
  1805. // -------------------------------------------------------
  1806. // Name: DrawRleAlphaFastMMX()
  1807. // Describe: 绘制RLE压缩后的位图(无裁减)
  1808. // -------------------------------------------------------
  1809. HRESULT CDisplay::DrawRleAlphaFastMMX(int x, int y, CBitmapX* pBitmapSrc, CBitmapX* pBitmapDest, int nAlpha)
  1810. {
  1811. DWORD rgbTemp;
  1812. int width, mod;
  1813. PIXEL* dest = (PIXEL*)pBitmapDest->m_pBuffer;
  1814. dest += x + y * pBitmapDest->m_nWidth; // 取得相对于ScreenBuffer的位置指针
  1815. PIXEL* pPixel = (PIXEL*)pBitmapSrc->m_pBuffer;
  1816. unsigned char* p = (unsigned char*)pBitmapSrc->m_pBuffer;
  1817. _asm // mm5 alpha
  1818. {
  1819. movd mm5, nAlpha
  1820. movq mm0, mm5
  1821. psllq mm0, 16
  1822. por mm5, mm0
  1823. movq mm0, mm5
  1824. psllq mm5, 32
  1825. por mm5, mm0
  1826. }
  1827. int other_alpha = 32-nAlpha;
  1828. _asm // mm6 32-alpha
  1829. {
  1830. movd mm6, other_alpha
  1831. movq mm0, mm6
  1832. psllq mm0, 16
  1833. por mm6, mm0
  1834. movq mm0, mm6
  1835. psllq mm6, 32
  1836. por mm6, mm0
  1837. }
  1838. for(int i=0; i<pBitmapSrc->m_nLength; i++)
  1839. {
  1840. switch(*p)
  1841. {
  1842. case BITMAP_RLE_LINE: // 绘制连续的不同色彩像素
  1843. {
  1844. pPixel++;
  1845. p++;
  1846. int l = *p;
  1847. p++;
  1848. width = l >> 2;
  1849. mod = l % 4;
  1850. for(int j=0; j<width; j++)
  1851. {
  1852. _asm
  1853. {
  1854. mov esi, pPixel
  1855. mov edi, dest
  1856. // read data from src & dest
  1857. movq mm4, [esi]
  1858. movq mm3, [edi]
  1859. movq mm0, mm4 // src
  1860. movq mm1, mm3 // dest
  1861. // alpha
  1862. pand mm0, RMASK // *src & RMASK
  1863. psrlw mm0, 5
  1864. pmullw mm0, mm5 // * nAlpha
  1865. pand mm1, RMASK // *dest & RMASK
  1866. psrlw mm1, 5
  1867. pmullw mm1, mm6 // * ialpha
  1868. paddusw mm0, mm1 // +
  1869. pand mm0, RMASK // RMASK &
  1870. // read data from src & dest
  1871. movq mm1, mm4 // src
  1872. movq mm2, mm3 // dest
  1873. // alpha
  1874. pand mm1, GMASK // *src & GMASK
  1875. pmullw mm1, mm5 // * nAlpha
  1876. pand mm2, GMASK // *dest & GMASK
  1877. pmullw mm2, mm6 // * ialpha
  1878. paddusw mm1, mm2 // +
  1879. psrlw mm1, 5 // >> 5
  1880. pand mm1, GMASK // GMASK &
  1881. por mm0, mm1 // |
  1882. // read data from src & dest
  1883. movq mm1, mm4 // src
  1884. movq mm2, mm3 // dest
  1885. // alpha
  1886. pand mm1, BMASK // *src & BMASK
  1887. pmullw mm1, mm5 // * nAlpha
  1888. pand mm2, BMASK // *dest & BMASK
  1889. pmullw mm2, mm6 // * ialpha
  1890. paddusw mm1, mm2 // +
  1891. psrlw mm1, 5 // >> 5
  1892. pand mm1, BMASK // BMASK &
  1893. por mm0, mm1 // |
  1894. // draw to dest buffer
  1895. movq [edi], mm0
  1896. add esi, 8
  1897. add edi, 8
  1898. mov pPixel, esi
  1899. mov dest, edi
  1900. }
  1901. i += 4;
  1902. p += 2*4;
  1903. }
  1904. if( mod == 1 )
  1905. {
  1906. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  1907. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1908. rgbTemp = rgbTemp & m_rgbMask;
  1909. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1910. dest++;
  1911. pPixel++;
  1912. i++;
  1913. p += 2;
  1914. }
  1915. else if( mod == 2 )
  1916. {
  1917. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  1918. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1919. rgbTemp = rgbTemp & m_rgbMask;
  1920. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1921. dest++;
  1922. pPixel++;
  1923. i++;
  1924. p += 2;
  1925. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  1926. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1927. rgbTemp = rgbTemp & m_rgbMask;
  1928. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1929. dest++;
  1930. pPixel++;
  1931. i++;
  1932. p += 2;
  1933. }
  1934. else if( mod == 3 )
  1935. {
  1936. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  1937. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1938. rgbTemp = rgbTemp & m_rgbMask;
  1939. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1940. dest++;
  1941. pPixel++;
  1942. i++;
  1943. p += 2;
  1944. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  1945. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1946. rgbTemp = rgbTemp & m_rgbMask;
  1947. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1948. dest++;
  1949. pPixel++;
  1950. i++;
  1951. p += 2;
  1952. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  1953. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1954. rgbTemp = rgbTemp & m_rgbMask;
  1955. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1956. dest++;
  1957. pPixel++;
  1958. i++;
  1959. p += 2;
  1960. }
  1961. /*
  1962. for(int j=0; j<l; j++)
  1963. {
  1964. rgbTemp = ((((*pPixel<<16)|*pPixel) & m_rgbMask ) * nAlpha
  1965. + (((*dest<<16)|*dest) & m_rgbMask ) * (32-nAlpha) ) >> 5;
  1966. rgbTemp = rgbTemp & m_rgbMask;
  1967. *dest = (WORD)((rgbTemp>>16)|rgbTemp);
  1968. dest++;
  1969. pPixel++;
  1970. i++;
  1971. p += 2;
  1972. }*/
  1973. }
  1974. break;
  1975. case BITMAP_RLE_COLORKEY:

Large files files are truncated, but you can click here to view the full file