WHDXGraphic.cpp
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:228k
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- }
- }
- m_pddsBackBuffer->Unlock(NULL);
- return TRUE;
- }
- return FALSE;
- }
- // nX, nY绰 吝缴痢狼 谅钎捞促.
- BOOL CWHDXGraphicWindow::DrawWithShadowABlend(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight,
- WORD* pwShadowClrSrc, BOOL bBlend, BYTE bShadowType, BYTE bOpa)
- {
- // 嘛瘤 臼绰 弊覆磊.
- if ( bShadowType == 48 )
- return FALSE;
- RECT rc;
- DDSURFACEDESC2 ddsd;
- INT nWidth = nXSize;
- INT nHeight = nYSize;
- INT nXOffset = 0;
- INT nYOffset = 0;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = wClipWidth -1;
- INT nEndY = wClipHeight-1;
- if ( m_pddsBackBuffer != NULL )
- {
- rc.left = 0;
- rc.right = nWidth;
- rc.top = 0;
- rc.bottom = nHeight;
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.lpSurface = NULL;
-
- m_pddsBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
- if ( !ddsd.lpSurface ) return FALSE;
- WORD* pwdDst;
- pwdDst = (WORD*)ddsd.lpSurface;
- INT nWidthStart = 0;
- INT nWidthEnd = 0;
- INT nCurrWidth = 0;
- INT nCntCopyWord = 0;
- INT nYCnt =0;
- INT nLastWidth = 0;
- INT nDstXPos = 0;
- INT nDstYPos = 0;
- WORD wPixel;
- BYTE bBlueWantedColor, bGreenWantedColor, bRedWantedColor, bBlueDst, bGreenDst, bRedDst;
- RECT rcScrnShadow;
- WORD wSahdowColor = pwShadowClrSrc[0];
- if ( bShadowType == 49 )
- {
- SetRect(&rcScrnShadow, nX, nY, nX+nHeight/2+nWidth, nY+nHeight/2);
- }
- else if ( bShadowType == 50 )
- {
- SetRect(&rcScrnShadow, nX, nY, nX+nWidth, nY+nHeight);
- }
- // y绵俊 措秦辑 角力肺 风俏矫懦 Count父阑 沥茄促.
- for ( nYCnt=rc.top ; nYCnt < rc.bottom ; nYCnt++ )
- {
- // 茄扼牢狼 辨捞甫 掘绢柯促.(窜困绰 况靛)
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- if ( bShadowType == 49 )
- {
- nDstYPos = nYCnt-nYCnt/2+nY;
- }
- else if ( bShadowType == 50 )
- {
- nDstYPos = nYCnt+nY;
- }
- if ( nDstYPos < 0 || nDstYPos >= wClipHeight || (bShadowType==49 && nYCnt%2) )
- {
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- continue;
- }
- // 扼牢狼 辨捞父怒 拳搁俊 谎妨霖促.
- for ( INT x = nWidthStart; x < nWidthEnd ; )
- {
- if ( pwSrc[x] == 0xC0 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nCurrWidth += nCntCopyWord;
- }
- else if ( pwSrc[x] == 0xC1 || pwSrc[x] == 0xC2 || pwSrc[x] == 0xC3 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( bShadowType == 49 )
- {
- nDstXPos = (nLastWidth+nX+(rc.bottom-nYCnt)/2);
- }
- else if ( bShadowType == 50 )
- {
- nDstXPos = (nLastWidth+nX);
- }
- if ( !bBlend )
- {
- // 哭率 吧副锭.
- if ( nDstXPos < 0 && nDstXPos+nCntCopyWord >= 0 )
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- if ( nDstXPos+nCheck >= 0 && nDstXPos+nCheck < wClipWidth )
- {
- pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck] = wSahdowColor;
- }
- }
- x += nCntCopyWord;
- }
- // 坷弗率 吧副锭.
- else if ( nDstXPos < wClipWidth && nDstXPos+nCntCopyWord >= wClipWidth )
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- if ( nDstXPos+nCheck >= 0 && nDstXPos+nCheck < wClipWidth )
- {
- pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck] = wSahdowColor;
- }
- }
- x += nCntCopyWord;
- }
- // 救吧副锭.
- else if ( nDstXPos >= 0 && nDstXPos+nCntCopyWord < wClipWidth )
- {
- memcpy(&pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos], pwShadowClrSrc, sizeof(WORD)*nCntCopyWord);
- // memset(&pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos], wSahdowColor, sizeof(WORD)*nCntCopyWord);
- x += nCntCopyWord;
- }
- else
- {
- x += nCntCopyWord;
- }
- }
- else
- {
- // 哭率 吧副锭.
- if ( nDstXPos < 0 && nDstXPos+nCntCopyWord >= 0 )
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- if ( nDstXPos+nCheck >= 0 && nDstXPos+nCheck < wClipWidth )
- {
- // pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck] = wSahdowColor;
- wPixel = wSahdowColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck];
- bBlueDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- bBlueDst = (BYTE)((bOpa*(bBlueDst -bBlueWantedColor)+100*bBlueWantedColor ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenWantedColor)+100*bGreenWantedColor) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedWantedColor)+100*bRedWantedColor ) / 100);
- pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<m_stBitsMaskInfo.bBShift));
- }
- }
- x += nCntCopyWord;
- }
- // 坷弗率 吧副锭.
- else if ( nDstXPos < wClipWidth && nDstXPos+nCntCopyWord >= wClipWidth )
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- if ( nDstXPos+nCheck >= 0 && nDstXPos+nCheck < wClipWidth )
- {
- // pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck] = wSahdowColor;
- WORD wPixel = wSahdowColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck];
- bBlueDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- bBlueDst = (BYTE)((bOpa*(bBlueDst -bBlueWantedColor)+100*bBlueWantedColor ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenWantedColor)+100*bGreenWantedColor) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedWantedColor)+100*bRedWantedColor ) / 100);
- pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<m_stBitsMaskInfo.bBShift));
- }
- }
- x += nCntCopyWord;
- }
- // 救吧副锭.
- else if ( nDstXPos >= 0 && nDstXPos+nCntCopyWord < wClipWidth )
- {
- // memset(&pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos], wSahdowColor, sizeof(WORD)*nCntCopyWord);
- // x += nCntCopyWord;
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- // pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck] = wSahdowColor;
- wPixel = wSahdowColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck];
- bBlueDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- bBlueDst = (BYTE)((bOpa*(bBlueDst -bBlueWantedColor)+100*bBlueWantedColor ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenWantedColor)+100*bGreenWantedColor) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedWantedColor)+100*bRedWantedColor ) / 100);
- pwdDst[(nDstYPos * (ddsd.lPitch >> 1)) + nDstXPos+nCheck] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- else
- {
- x += nCntCopyWord;
- }
- }
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- }
-
- m_pddsBackBuffer->Unlock(NULL);
- return TRUE;
- }
- return FALSE;
- }
- VOID CWHDXGraphicWindow::DrawWithShadowABlend(INT nX, INT nY, INT nXSize, INT nYSize, INT nPX, INT nPY, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight,
- WORD* pwShadowClrSrc, BOOL bBlend, BYTE bOpa)
- {
- DDSURFACEDESC2 ddsd;
- #define _HALF_CELL_WIDTH 24
- #define _HALF_CELL_HEIGHT 16
- // 拳搁(800*600)俊辑 弊覆磊啊 嘛鳃 荤捞令甫 备茄促.
-
- // 拳搁(800*600)俊辑狼 伎矫累谅钎啊 酒囱 角力 吝缴痢 谅钎(伎困 沥吝居痢捞促.)
- INT nScrnCenterX = nX - nPX + 24;//_HALF_CELL_WIDTH;
- INT nScrnCenterY = nY - nPY + 16;//_HALF_CELL_HEIGHT;
- INT nRealCenterX = nX - nScrnCenterX;
- INT nRealCenterY = nY - nScrnCenterY;
- INT nShadowCenterX = nX;
- INT nShadowCenterY = nY-nRealCenterY/2;
- RECT rcSrc = {0, 0, nXSize, nYSize};
- BYTE bRedDst, bGreenDst, bBlueDst;
- BYTE bRedWantedColor, bGreenWantedColor, bBlueWantedColor;
- WORD wPixel;
- WORD wSahdowColor = pwShadowClrSrc[0];
- if ( m_pddsBackBuffer != NULL )
- {
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.lpSurface = NULL;
- m_pddsBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
- if ( !ddsd.lpSurface ) return;
- WORD* pwdDst = NULL;
- pwdDst = (WORD*)ddsd.lpSurface;
- if ( pwdDst )
- {
- INT nWidthStart = 0;
- INT nWidthEnd = 0;
- INT nCurrWidth = 0;
- INT nLastWidth = 0;
- INT nCntCopyWord = 0;
- INT nYCnt = 0;
- INT nDstYPos = nShadowCenterY;
- for ( nYCnt=rcSrc.top ; nYCnt < rcSrc.bottom ; nYCnt++ )
- {
- if ( nDstYPos >= wClipHeight )
- {
- m_pddsBackBuffer->Unlock(NULL);
- return;
- }
- // y绵 努府俏棺 茄临究 扒呈顿扁.
- if ( nYCnt%2 == 0 || nDstYPos < 0 )
- {
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nDstYPos++;
- }
- else
- {
- // 茄扼牢狼 辨捞甫 掘绢柯促.(窜困绰 况靛)
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- // 扼牢狼 辨捞父怒 拳搁俊 谎妨霖促.
- for ( INT x = nWidthStart; x < nWidthEnd ; )
- {
- if ( pwSrc[x] == 0xC0 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nCurrWidth += nCntCopyWord;
- }
- else
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( bBlend )
- {
- if ((nShadowCenterX+nLastWidth+((-nRealCenterY/2)-nYCnt/2)) < 0 && (nShadowCenterX+nCurrWidth+((-nRealCenterY/2)-nYCnt/2)) >= 0 )
- {
- }
- else if ((nShadowCenterX+nLastWidth+((-nRealCenterY/2)-nYCnt/2)) < wClipWidth && (nShadowCenterX+nCurrWidth+((-nRealCenterY/2)-nYCnt/2)) >= wClipWidth )
- {
- }
- else if ( (nShadowCenterX+nCurrWidth+((-nRealCenterY/2)-nYCnt/2)) < 0 )
- {
- }
- else if ( (nShadowCenterX+nCurrWidth+((-nRealCenterY/2)-nYCnt/2)) >= wClipWidth )
- {
- }
- else
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- wPixel = wSahdowColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwdDst[nDstYPos*(ddsd.lPitch >> 1) + (nShadowCenterX+nLastWidth+((-nRealCenterY/2)-nYCnt/2)) + nCheck];
- bBlueDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- bBlueDst = (BYTE)((bOpa*(bBlueDst -bBlueWantedColor)+100*bBlueWantedColor ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenWantedColor)+100*bGreenWantedColor) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedWantedColor)+100*bRedWantedColor ) / 100);
- pwdDst[nDstYPos*(ddsd.lPitch >> 1) + (nShadowCenterX+nLastWidth+((-nRealCenterY/2)-nYCnt/2)+nCheck)] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<m_stBitsMaskInfo.bBShift)); }
- }
- }
- else
- {
- if ((nShadowCenterX+nLastWidth+((-nRealCenterY/2)-nYCnt/2)) < 0 && (nShadowCenterX+nCurrWidth+((-nRealCenterY/2)-nYCnt/2)) >= 0 )
- {
- }
- else if ((nShadowCenterX+nLastWidth+((-nRealCenterY/2)-nYCnt/2)) < wClipWidth && (nShadowCenterX+nCurrWidth+((-nRealCenterY/2)-nYCnt/2)) >= wClipWidth )
- {
- }
- else if ( (nShadowCenterX+nCurrWidth+((-nRealCenterY/2)-nYCnt/2)) < 0 )
- {
- }
- else if ( (nShadowCenterX+nCurrWidth+((-nRealCenterY/2)-nYCnt/2)) >= wClipWidth )
- {
- }
- else
- {
- // memset(&pwdDst[nDstYPos*(ddsd.lPitch >> 1) + (nShadowCenterX+nLastWidth+((-nRealCenterY/2)-nYCnt/2))], wSahdowColor, sizeof(WORD)*nCntCopyWord);
- memcpy(&pwdDst[nDstYPos*(ddsd.lPitch >> 1) + (nShadowCenterX+nLastWidth+((-nRealCenterY/2)-nYCnt/2))], pwShadowClrSrc, sizeof(WORD)*nCntCopyWord);
- }
- }
- x += nCntCopyWord;
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- }
- }
- m_pddsBackBuffer->Unlock(NULL);
- }
- }
- }
- BOOL CWHDXGraphicWindow::DrawWithABlendCompDataWithLightedColor(INT nX, INT nY,
- INT nXSize, INT nYSize, WORD* pwSrc,
- WORD wClipWidth, WORD wClipHeight,
- WORD wChooseColor1, WORD wChooseColor2)
- {
- RECT rc;
- DDSURFACEDESC2 ddsd;
- INT nWidth = nXSize;
- INT nHeight = nYSize;
- INT nXOffset = 0;
- INT nYOffset = 0;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = wClipWidth -1;
- INT nEndY = wClipHeight-1;
- FLOAT fBright = 0.3f;
- if ( m_pddsBackBuffer != NULL )
- {
- if (nX < nStartX )
- {
- nXOffset = nStartX - nX;
- nWidth = nXSize - nXOffset;
- }
- if ( (nX+nXSize-1) > nEndX )
- nWidth = nEndX - nX - nXOffset + 1;
- if ( nY < nStartY )
- {
- nYOffset = nStartY - nY;
- nHeight = nYSize - nYOffset;
- }
- if ( (nY+nYSize-1) > nEndY )
- nHeight = nEndY - nY - nYOffset + 1;
- if ( (nWidth > 0) && (nHeight > 0) )
- {
- rc.left = nXOffset;
- rc.right = nXOffset+nWidth;
- rc.top = nYOffset;
- rc.bottom = nYOffset+nHeight;
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.lpSurface = NULL;
-
- m_pddsBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
- if ( !ddsd.lpSurface ) return FALSE;
- WORD* pwdDst;
- pwdDst = (WORD*)ddsd.lpSurface;
- INT nWidthStart = 0;
- INT nWidthEnd = 0;
- INT nCurrWidth = 0;
- INT nCntCopyWord = 0;
- INT nYCnt =0;
- INT nLastWidth = 0;
- BYTE bRedWantedColor, bGreenWantedColor, bBlueWantedColor;
- BYTE bRedSrc, bGreenSrc, bBlueSrc;
- WORD wPixel;
- WORD wDyingKind, wChooseColor;
- FLOAT rBlueRate, rGreenRate, bRedRate;
- // y绵 努府俏.
- for ( nYCnt=0 ; nYCnt < rc.top ; nYCnt++ )
- {
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- }
- // y绵俊 措秦辑 角力肺 风俏矫懦 Count父阑 沥茄促.
- for ( nYCnt=rc.top ; nYCnt < rc.bottom ; nYCnt++ )
- {
- // 茄扼牢狼 辨捞甫 掘绢柯促.(窜困绰 况靛)
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- // 扼牢狼 辨捞父怒 拳搁俊 谎妨霖促.
- for ( INT x = nWidthStart; x < nWidthEnd ; )
- {
- if ( pwSrc[x] == 0xC0 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nCurrWidth += nCntCopyWord;
- }
- else if ( pwSrc[x] == 0xC1 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rc.left > nCurrWidth || rc.right < nLastWidth )
- {
- x += nCntCopyWord;
- }
- else
- {
- // rc.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth < rc.left && rc.left <= nCurrWidth )
- {
- x += (rc.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < nCurrWidth-rc.left; nCheck++ )
- {
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueSrc = (BYTE)((FLOAT)bBlueSrc + ((FLOAT)bBlueSrc*rBlueRate*fBright));
- bGreenSrc = (BYTE)((FLOAT)bGreenSrc + ((FLOAT)bGreenSrc*rGreenRate*fBright));
- bRedSrc = (BYTE)((FLOAT)bRedSrc + ((FLOAT)bRedSrc*bRedRate*fBright));
- if ( bBlueSrc > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueSrc = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenSrc > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenSrc = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedSrc > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedSrc = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX+nCheck)] = ((bBlueSrc <<m_stBitsMaskInfo.bBShift) |
- (bGreenSrc<<m_stBitsMaskInfo.bGShift) |
- (bRedSrc <<m_stBitsMaskInfo.bRShift));
- }
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- for ( INT nCheck = 0; nCheck < rc.right-nLastWidth; nCheck++ )
- {
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueSrc = (BYTE)((FLOAT)bBlueSrc + ((FLOAT)bBlueSrc*rBlueRate*fBright));
- bGreenSrc = (BYTE)((FLOAT)bGreenSrc + ((FLOAT)bGreenSrc*rGreenRate*fBright));
- bRedSrc = (BYTE)((FLOAT)bRedSrc + ((FLOAT)bRedSrc*bRedRate*fBright));
- if ( bBlueSrc > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueSrc = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenSrc > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenSrc = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedSrc > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedSrc = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bBlueSrc <<m_stBitsMaskInfo.bRShift) |
- (bGreenSrc<<m_stBitsMaskInfo.bGShift) |
- (bRedSrc <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- else
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueSrc = (BYTE)((FLOAT)bBlueSrc + ((FLOAT)bBlueSrc*rBlueRate*fBright));
- bGreenSrc = (BYTE)((FLOAT)bGreenSrc + ((FLOAT)bGreenSrc*rGreenRate*fBright));
- bRedSrc = (BYTE)((FLOAT)bRedSrc + ((FLOAT)bRedSrc*bRedRate*fBright));
- if ( bBlueSrc > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueSrc = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenSrc > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenSrc = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedSrc > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedSrc = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bBlueSrc <<m_stBitsMaskInfo.bBShift) |
- (bGreenSrc<<m_stBitsMaskInfo.bGShift) |
- (bRedSrc <<m_stBitsMaskInfo.bRShift));
- }
- x += nCntCopyWord;
- }
- }
- }
- else if ( pwSrc[x] == 0xC2 || pwSrc[x] == 0xC3 )
- {
- wDyingKind = pwSrc[x];
- switch ( wDyingKind )
- {
- case 0xC2:
- wChooseColor = wChooseColor1;
- break;
- case 0xC3:
- wChooseColor = wChooseColor2;
- break;
- }
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rc.left > nCurrWidth || rc.right < nLastWidth )
- {
- x += nCntCopyWord;
- }
- else
- {
- // rc.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth < rc.left && rc.left <= nCurrWidth )
- {
- x += (rc.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < nCurrWidth-rc.left; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- bBlueSrc = bBlueWantedColor;
- bGreenSrc = bGreenWantedColor;
- bRedSrc = bRedWantedColor;
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueSrc = (BYTE)((FLOAT)bBlueSrc + ((FLOAT)bBlueSrc*rBlueRate*fBright));
- bGreenSrc = (BYTE)((FLOAT)bGreenSrc + ((FLOAT)bGreenSrc*rGreenRate*fBright));
- bRedSrc = (BYTE)((FLOAT)bRedSrc + ((FLOAT)bRedSrc*bRedRate*fBright));
- if ( bBlueSrc > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueSrc = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenSrc > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenSrc = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedSrc > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedSrc = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX+nCheck)] = ((bBlueSrc <<m_stBitsMaskInfo.bBShift) |
- (bGreenSrc<<m_stBitsMaskInfo.bGShift) |
- (bRedSrc <<m_stBitsMaskInfo.bRShift));
- }
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- for ( INT nCheck = 0; nCheck < rc.right-nLastWidth; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- bBlueSrc = bBlueWantedColor;
- bGreenSrc = bGreenWantedColor;
- bRedSrc = bRedWantedColor;
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueSrc = (BYTE)((FLOAT)bBlueSrc + ((FLOAT)bBlueSrc*rBlueRate*fBright));
- bGreenSrc = (BYTE)((FLOAT)bGreenSrc + ((FLOAT)bGreenSrc*rGreenRate*fBright ));
- bRedSrc = (BYTE)((FLOAT)bRedSrc + ((FLOAT)bRedSrc*bRedRate*fBright));
- if ( bBlueSrc > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueSrc = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenSrc > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenSrc = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedSrc > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedSrc = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bBlueSrc <<m_stBitsMaskInfo.bRShift) |
- (bGreenSrc<<m_stBitsMaskInfo.bGShift) |
- (bRedSrc <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- else
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- bBlueSrc = bBlueWantedColor;
- bGreenSrc = bGreenWantedColor;
- bRedSrc = bRedWantedColor;
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueSrc = (BYTE)((FLOAT)bBlueSrc + ((FLOAT)bBlueSrc*rBlueRate*fBright));
- bGreenSrc = (BYTE)((FLOAT)bGreenSrc + ((FLOAT)bGreenSrc*rGreenRate*fBright));
- bRedSrc = (BYTE)((FLOAT)bRedSrc + ((FLOAT)bRedSrc*bRedRate*fBright));
- if ( bBlueSrc > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueSrc = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenSrc > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenSrc = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedSrc > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedSrc = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bBlueSrc <<m_stBitsMaskInfo.bBShift) |
- (bGreenSrc<<m_stBitsMaskInfo.bGShift) |
- (bRedSrc <<m_stBitsMaskInfo.bRShift));
- }
- x += nCntCopyWord;
- }
- }
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- }
- }
- m_pddsBackBuffer->Unlock(NULL);
- return TRUE;
- }
- return FALSE;
- }
- BOOL CWHDXGraphicWindow::DrawWithImageForCompClipRgnColor(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight, WORD wColor, BOOL bFocused, BOOL bBlend)
- {
- RECT rc;
- DDSURFACEDESC2 ddsd;
- INT nWidth = nXSize;
- INT nHeight = nYSize;
- INT nXOffset = 0;
- INT nYOffset = 0;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = wClipWidth -1;
- INT nEndY = wClipHeight-1;
- if ( m_pddsBackBuffer != NULL )
- {
- if (nX < nStartX )
- {
- nXOffset = nStartX - nX;
- nWidth = nXSize - nXOffset;
- }
- if ( (nX+nXSize-1) > nEndX )
- nWidth = nEndX - nX - nXOffset + 1;
- if ( nY < nStartY )
- {
- nYOffset = nStartY - nY;
- nHeight = nYSize - nYOffset;
- }
- if ( (nY+nYSize-1) > nEndY )
- nHeight = nEndY - nY - nYOffset + 1;
- if ( (nWidth > 0) && (nHeight > 0) )
- {
- rc.left = nXOffset;
- rc.right = nXOffset+nWidth;
- rc.top = nYOffset;
- rc.bottom = nYOffset+nHeight;
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.lpSurface = NULL;
-
- m_pddsBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
- if ( !ddsd.lpSurface ) return FALSE;
- WORD* pwdDst;
- pwdDst = (WORD*)ddsd.lpSurface;
- INT nWidthStart = 0;
- INT nWidthEnd = 0;
- INT nCurrWidth = 0;
- INT nCntCopyWord = 0;
- INT nYCnt =0;
- INT nLastWidth = 0;
- BYTE bRedStateColor, bGreenStateColor, bBlueStateColor;
- BYTE bRedSrc, bGreenSrc, bBlueSrc;
- BYTE bBlueDst, bGreenDst, bRedDst;
- WORD wPixel;
- FLOAT rBlueRate, rGreenRate, rRedRate;
- FLOAT rbLightRate = 0.0f;
- // y绵 努府俏.
- for ( nYCnt=0 ; nYCnt < rc.top ; nYCnt++ )
- {
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- }
- // y绵俊 措秦辑 角力肺 风俏矫懦 Count父阑 沥茄促.
- for ( nYCnt=rc.top ; nYCnt < rc.bottom ; nYCnt++ )
- {
- // 茄扼牢狼 辨捞甫 掘绢柯促.(窜困绰 况靛)
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- // 扼牢狼 辨捞父怒 拳搁俊 谎妨霖促.
- for ( INT x = nWidthStart; x < nWidthEnd ; )
- {
- if ( pwSrc[x] == 0xC0 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nCurrWidth += nCntCopyWord;
- }
- else if ( pwSrc[x] == 0xC1 || pwSrc[x] == 0xC2 || pwSrc[x] == 0xC3 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rc.left > nCurrWidth || rc.right < nLastWidth )
- {
- x += nCntCopyWord;
- }
- else
- {
- // rc.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth < rc.left && rc.left <= nCurrWidth )
- {
- x += (rc.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < nCurrWidth-rc.left; nCheck++ )
- {
- wPixel = wColor;
- bBlueStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- // Focus咯何.
- if ( bFocused ) rbLightRate = 0.6f;
- else rbLightRate = 0.0f;
- if ( !wColor )
- {
- BYTE bTemp = (BYTE)(bBlueSrc+(bGreenSrc>>1)+bRedSrc)/3;
- bTemp = bTemp + (BYTE)(bTemp*rbLightRate);
- if ( bTemp > 31 ) bTemp = 31;
- bBlueStateColor = bRedStateColor = bTemp;
- bGreenStateColor = bTemp<<1;
- }
- else
- {
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- rRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueStateColor = ( (BYTE)((FLOAT)bBlueStateColor *rBlueRate ) + (BYTE)((FLOAT)bBlueStateColor *rBlueRate *rbLightRate) );
- bGreenStateColor = ( (BYTE)((FLOAT)bGreenStateColor*rGreenRate) + (BYTE)((FLOAT)bGreenStateColor*rGreenRate*rbLightRate) );
- bRedStateColor = ( (BYTE)((FLOAT)bRedStateColor *rRedRate ) + (BYTE)((FLOAT)bRedStateColor *rRedRate *rbLightRate) );
- if ( bBlueStateColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueStateColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenStateColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenStateColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedStateColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedStateColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- }
- if ( bBlend )
- {
- wPixel = pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)];
- bBlueDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- bBlueDst = (BYTE)((50*(bBlueDst -bBlueStateColor )+100*bBlueStateColor ) / 100);
- bGreenDst = (BYTE)((50*(bGreenDst-bGreenStateColor)+100*bGreenStateColor ) / 100);
- bRedDst = (BYTE)((50*(bRedDst -bRedStateColor )+100*bRedStateColor ) / 100);
- }
- else
- {
- bBlueDst = bBlueStateColor;
- bGreenDst = bGreenStateColor;
- bRedDst = bRedStateColor;
- }
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX+nCheck)] = ((bBlueDst <<m_stBitsMaskInfo.bBShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bRedDst <<m_stBitsMaskInfo.bRShift));
- }
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- for ( INT nCheck = 0; nCheck < rc.right-nLastWidth; nCheck++ )
- {
- wPixel = wColor;
- bBlueStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- // Focus咯何.
- if ( bFocused ) rbLightRate = 0.6f;
- else rbLightRate = 0.0f;
- if ( !wColor )
- {
- BYTE bTemp = (BYTE)(bBlueSrc+(bGreenSrc>>1)+bRedSrc)/3;
- bTemp = bTemp + (BYTE)(bTemp*rbLightRate);
- if ( bTemp > 31 ) bTemp = 31;
- bBlueStateColor = bRedStateColor = bTemp;
- bGreenStateColor = bTemp<<1;
- }
- else
- {
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- rRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueStateColor = ( (BYTE)((FLOAT)bBlueStateColor *rBlueRate ) + (BYTE)((FLOAT)bBlueStateColor *rBlueRate *rbLightRate) );
- bGreenStateColor = ( (BYTE)((FLOAT)bGreenStateColor*rGreenRate) + (BYTE)((FLOAT)bGreenStateColor*rGreenRate*rbLightRate) );
- bRedStateColor = ( (BYTE)((FLOAT)bRedStateColor *rRedRate ) + (BYTE)((FLOAT)bRedStateColor *rRedRate *rbLightRate) );
- if ( bBlueStateColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueStateColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenStateColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenStateColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedStateColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedStateColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- }
- if ( bBlend )
- {
- wPixel = pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)];
- bBlueDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- bBlueDst = (BYTE)((50*(bBlueDst -bBlueStateColor )+100*bBlueStateColor ) / 100);
- bGreenDst = (BYTE)((50*(bGreenDst-bGreenStateColor)+100*bGreenStateColor ) / 100);
- bRedDst = (BYTE)((50*(bRedDst -bRedStateColor )+100*bRedStateColor ) / 100);
- }
- else
- {
- bBlueDst = bBlueStateColor;
- bGreenDst = bGreenStateColor;
- bRedDst = bRedStateColor;
- }
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bBlueDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bRedDst <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- else
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- wPixel = wColor;
- bBlueStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- // Focus咯何.
- if ( bFocused ) rbLightRate = 0.6f;
- else rbLightRate = 0.0f;
- if ( !wColor )
- {
- BYTE bTemp = (BYTE)(bBlueSrc+(bGreenSrc>>1)+bRedSrc)/3;
- bTemp = bTemp + (BYTE)(bTemp*rbLightRate);
- if ( bTemp > 31 ) bTemp = 31;
- bBlueStateColor = bRedStateColor = bTemp;
- bGreenStateColor = bTemp<<1;
- }
- else
- {
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- rRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueStateColor = ( (BYTE)((FLOAT)bBlueStateColor *rBlueRate ) + (BYTE)((FLOAT)bBlueStateColor *rBlueRate *rbLightRate) );
- bGreenStateColor = ( (BYTE)((FLOAT)bGreenStateColor*rGreenRate) + (BYTE)((FLOAT)bGreenStateColor*rGreenRate*rbLightRate) );
- bRedStateColor = ( (BYTE)((FLOAT)bRedStateColor *rRedRate ) + (BYTE)((FLOAT)bRedStateColor *rRedRate *rbLightRate) );
- if ( bBlueStateColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueStateColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenStateColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenStateColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedStateColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedStateColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- }
- if ( bBlend )
- {
- wPixel = pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)];
- bBlueDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedDst = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- bBlueDst = (BYTE)((50*(bBlueDst -bBlueStateColor )+100*bBlueStateColor ) / 100);
- bGreenDst = (BYTE)((50*(bGreenDst-bGreenStateColor)+100*bGreenStateColor ) / 100);
- bRedDst = (BYTE)((50*(bRedDst -bRedStateColor )+100*bRedStateColor ) / 100);
- }
- else
- {
- bBlueDst = bBlueStateColor;
- bGreenDst = bGreenStateColor;
- bRedDst = bRedStateColor;
- }
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bBlueDst <<m_stBitsMaskInfo.bBShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bRedDst <<m_stBitsMaskInfo.bRShift));
- }
- x += nCntCopyWord;
- }
- }
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- }
- }
- m_pddsBackBuffer->Unlock(NULL);
- return TRUE;
- }
- return FALSE;
- }
- BOOL CWHDXGraphicWindow::DrawWithImageForCompClipRgnColor(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight,WORD wColor , WORD wChooseColor1, WORD wChooseColor2)
- {
- RECT rc;
- DDSURFACEDESC2 ddsd;
- INT nWidth = nXSize;
- INT nHeight = nYSize;
- INT nXOffset = 0;
- INT nYOffset = 0;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = wClipWidth -1;
- INT nEndY = wClipHeight-1;
- INT FiveMiddle = 0xf;
- INT SixMiddle = 0x1f;
- BYTE bsBlueColor,bsGreenColor,bsRedColor;
- BYTE bdBlueColor,bdGreenColor,bdRedColor;
- bdBlueColor = (BYTE)((wColor & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bdGreenColor = (BYTE)((wColor & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bdRedColor = (BYTE)((wColor & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- if ( m_pddsBackBuffer != NULL )
- {
- if (nX < nStartX )
- {
- nXOffset = nStartX - nX;
- nWidth = nXSize - nXOffset;
- }
- if ( (nX+nXSize-1) > nEndX )
- nWidth = nEndX - nX - nXOffset + 1;
- if ( nY < nStartY )
- {
- nYOffset = nStartY - nY;
- nHeight = nYSize - nYOffset;
- }
- if ( (nY+nYSize-1) > nEndY )
- nHeight = nEndY - nY - nYOffset + 1;
- if ( (nWidth > 0) && (nHeight > 0) )
- {
- rc.left = nXOffset;
- rc.right = nXOffset+nWidth;
- rc.top = nYOffset;
- rc.bottom = nYOffset+nHeight;
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.lpSurface = NULL;
-
- m_pddsBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
- if ( !ddsd.lpSurface ) return FALSE;
- WORD* pwdDst;
- pwdDst = (WORD*)ddsd.lpSurface;
- INT nWidthStart = 0;
- INT nWidthEnd = 0;
- INT nCurrWidth = 0;
- INT nCntCopyWord = 0;
- INT nYCnt =0;
- INT nLastWidth = 0;
- FLOAT rBlueRate, rGreenRate, bRedRate;
- BYTE bRedSrc, bGreenSrc, bBlueSrc;
- BYTE bRedWantedColor, bGreenWantedColor, bBlueWantedColor;
- WORD wPixel;
- // y绵 努府俏.
- for ( nYCnt=0 ; nYCnt < rc.top ; nYCnt++ )
- {
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- }
- // y绵俊 措秦辑 角力肺 风俏矫懦 Count父阑 沥茄促.
- for ( nYCnt=rc.top ; nYCnt < rc.bottom ; nYCnt++ )
- {
- // 茄扼牢狼 辨捞甫 掘绢柯促.(窜困绰 况靛)
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- // 扼牢狼 辨捞父怒 拳搁俊 谎妨霖促.
- for ( INT x = nWidthStart; x < nWidthEnd ; )
- {
- if ( pwSrc[x] == 0xC0 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nCurrWidth += nCntCopyWord;
- }
- else if ( pwSrc[x] == 0xC1 )
- {
- x++;
- nCntCopyWord = pwSrc[x]; // 肮荐
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rc.left > nCurrWidth || rc.right < nLastWidth )
- {
- x += nCntCopyWord; // 倔配 寸配 臼篮 版快
- }
- else
- {
- // rc.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth < rc.left && rc.left <= nCurrWidth )
- {
- x += (rc.left-nLastWidth);
- for(WORD i = 0 ; i < (sizeof(WORD)*(nCurrWidth-rc.left)/2);i++)
- {
- bsBlueColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bsGreenColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bsRedColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- BYTE temp;
- temp = (bsRedColor+(bsGreenColor>>1)+bsBlueColor)/3;
- bsBlueColor = temp>0 ? (temp&bdBlueColor) : 0;
- bsGreenColor = temp>0 ? (temp&(bdGreenColor<<1)) : 0;
- bsRedColor = temp>0 ? (temp&bdRedColor) : 0;
- if ( bsBlueColor >= 32 ) bsBlueColor = 31;
- if ( bsGreenColor >= 64 ) bsGreenColor = 63;
- if ( bsRedColor >= 32 ) bsRedColor = 31;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX) + i] = (bsBlueColor<<m_stBitsMaskInfo.bBShift) | (bsGreenColor<<m_stBitsMaskInfo.bGShift) | (bsRedColor<<m_stBitsMaskInfo.bRShift);
- }
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- for(WORD i = 0 ; i < (sizeof(WORD)*(rc.right-nLastWidth));i++)
- {
- bsBlueColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bsGreenColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bsRedColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
-
- BYTE temp;
- temp = (bsRedColor+(bsGreenColor>>1)+bsBlueColor)/3;
- bsBlueColor = temp>0 ? (temp&bdBlueColor) : 0;
- bsGreenColor = temp>0 ? (temp&(bdGreenColor<<1)) : 0;
- bsRedColor = temp>0 ? (temp&bdRedColor) : 0;
- if ( bsBlueColor >= 32 ) bsBlueColor = 31;
- if ( bsGreenColor >= 64 ) bsGreenColor = 63;
- if ( bsRedColor >= 32 ) bsRedColor = 31;
-
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX) + i] = (bsBlueColor<<m_stBitsMaskInfo.bBShift) | (bsGreenColor<<m_stBitsMaskInfo.bGShift) | (bsRedColor<<m_stBitsMaskInfo.bRShift);
- }
- // memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*(rc.right-nLastWidth));
- x += nCntCopyWord;
- }
- else
- {
- for(WORD i = 0 ; i < (sizeof(WORD)*nCntCopyWord/2);i++)
- {
- bsBlueColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bsGreenColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bsRedColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- BYTE temp;
- temp = (bsRedColor+(bsGreenColor>>1)+bsBlueColor)/3;
- bsBlueColor = temp>0 ? (temp&bdBlueColor) : 0;
- bsGreenColor = temp>0 ? (temp&(bdGreenColor<<1)) : 0;
- bsRedColor = temp>0 ? (temp&bdRedColor) : 0;
- if ( bsBlueColor >= 32 ) bsBlueColor = 31;
- if ( bsGreenColor >= 64 ) bsGreenColor = 63;
- if ( bsRedColor >= 32 ) bsRedColor = 31;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX) + i] = (bsBlueColor<<m_stBitsMaskInfo.bBShift) | (bsGreenColor<<m_stBitsMaskInfo.bGShift) | (bsRedColor<<m_stBitsMaskInfo.bRShift);
- }
- x += nCntCopyWord;
- }
- }
- }
- else if ( pwSrc[x] == 0xC2 || pwSrc[x] == 0xC3 )
- {
- WORD wDyingKind, wChooseColor;
- wDyingKind = pwSrc[x];
- switch ( wDyingKind )
- {
- case 0xC2:
- wChooseColor = wChooseColor1;
- break;
- case 0xC3:
- wChooseColor = wChooseColor2;
- break;
- }
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rc.left > nCurrWidth || rc.right < nLastWidth )
- {
- x += nCntCopyWord;
- }
- else
- {
- // rc.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth < rc.left && rc.left <= nCurrWidth )
- {
- x += (rc.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < nCurrWidth-rc.left; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- BYTE temp;
- temp = (bsRedColor+(bGreenWantedColor>>1)+bBlueWantedColor)/3;
- bBlueWantedColor = temp>0 ? (temp&bdBlueColor) : 0;
- bGreenWantedColor = temp>0 ? (temp&(bdGreenColor<<1)) : 0;
- bRedWantedColor = temp>0 ? (temp&bdRedColor) : 0;
- if ( bBlueWantedColor >= 32 ) bBlueWantedColor = 31;
- if ( bGreenWantedColor >= 64 ) bGreenWantedColor = 63;
- if ( bRedWantedColor >= 32 ) bRedWantedColor = 31;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- for ( INT nCheck = 0; nCheck < rc.right-nLastWidth; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- BYTE temp;
- temp = (bsRedColor+(bGreenWantedColor>>1)+bBlueWantedColor)/3;
- bBlueWantedColor = temp>0 ? (temp&bdBlueColor) : 0;
- bGreenWantedColor = temp>0 ? (temp&(bdGreenColor<<1)) : 0;
- bRedWantedColor = temp>0 ? (temp&bdRedColor) : 0;
- if ( bBlueWantedColor >= 32 ) bBlueWantedColor = 31;
- if ( bGreenWantedColor >= 64 ) bGreenWantedColor = 63;
- if ( bRedWantedColor >= 32 ) bRedWantedColor = 31;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- else
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- BYTE temp;
- temp = (bsRedColor+(bGreenWantedColor>>1)+bBlueWantedColor)/3;
- bBlueWantedColor = temp>0 ? (temp&bdBlueColor) : 0;
- bGreenWantedColor = temp>0 ? (temp&(bdGreenColor<<1)) : 0;
- bRedWantedColor = temp>0 ? (temp&bdRedColor) : 0;
- if ( bBlueWantedColor >= 32 ) bBlueWantedColor = 31;
- if ( bGreenWantedColor >= 64 ) bGreenWantedColor = 63;
- if ( bRedWantedColor >= 32 ) bRedWantedColor = 31;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- }
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- }
- }
- m_pddsBackBuffer->Unlock(NULL);
- return TRUE;
- }
- return FALSE;
- }
- BOOL CWHDXGraphicWindow::DrawWithImageForCompClipRgnGray(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc , WORD wClipWidth, WORD wClipHeight, WORD wChooseColor1, WORD wChooseColor2)
- {
- RECT rc;
- DDSURFACEDESC2 ddsd;
- INT nWidth = nXSize;
- INT nHeight = nYSize;
- INT nXOffset = 0;
- INT nYOffset = 0;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = wClipWidth -1;
- INT nEndY = wClipHeight-1;
- INT FiveMiddle = 0xf;
- INT SixMiddle = 0x1f;
- BYTE bsBlueColor,bsGreenColor,bsRedColor;
- BYTE bdBlueColor,bdGreenColor,bdRedColor;
- bdBlueColor = 0x0f;
- bdGreenColor = 0x1f;
- bdRedColor = 0x0f;
- if ( m_pddsBackBuffer != NULL )
- {
- if (nX < nStartX )
- {
- nXOffset = nStartX - nX;
- nWidth = nXSize - nXOffset;
- }
- if ( (nX+nXSize-1) > nEndX )
- nWidth = nEndX - nX - nXOffset + 1;
- if ( nY < nStartY )
- {
- nYOffset = nStartY - nY;
- nHeight = nYSize - nYOffset;
- }
- if ( (nY+nYSize-1) > nEndY )
- nHeight = nEndY - nY - nYOffset + 1;
- if ( (nWidth > 0) && (nHeight > 0) )
- {
- rc.left = nXOffset;
- rc.right = nXOffset+nWidth;
- rc.top = nYOffset;
- rc.bottom = nYOffset+nHeight;
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.lpSurface = NULL;
-
- m_pddsBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
- if ( !ddsd.lpSurface ) return FALSE;
- WORD* pwdDst;
- pwdDst = (WORD*)ddsd.lpSurface;
- INT nWidthStart = 0;
- INT nWidthEnd = 0;
- INT nCurrWidth = 0;
- INT nCntCopyWord = 0;
- INT nYCnt =0;
- INT nLastWidth = 0;
- FLOAT rBlueRate, rGreenRate, bRedRate;
- BYTE bRedSrc, bGreenSrc, bBlueSrc;
- BYTE bRedWantedColor, bGreenWantedColor, bBlueWantedColor;
- WORD wPixel;
- // y绵 努府俏.
- for ( nYCnt=0 ; nYCnt < rc.top ; nYCnt++ )
- {
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- }
- // y绵俊 措秦辑 角力肺 风俏矫懦 Count父阑 沥茄促.
- for ( nYCnt=rc.top ; nYCnt < rc.bottom ; nYCnt++ )
- {
- // 茄扼牢狼 辨捞甫 掘绢柯促.(窜困绰 况靛)
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- // 扼牢狼 辨捞父怒 拳搁俊 谎妨霖促.
- for ( INT x = nWidthStart; x < nWidthEnd ; )
- {
- if ( pwSrc[x] == 0xC0 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nCurrWidth += nCntCopyWord;
- }
- else if ( pwSrc[x] == 0xC1 )
- {
- x++;
- nCntCopyWord = pwSrc[x]; // 肮荐
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rc.left > nCurrWidth || rc.right < nLastWidth )
- {
- x += nCntCopyWord; // 倔配 寸配 臼篮 版快
- }
- else
- {
- // rc.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth < rc.left && rc.left <= nCurrWidth )
- {
- x += (rc.left-nLastWidth);
- for(WORD i = 0 ; i < (sizeof(WORD)*(nCurrWidth-rc.left)/2);i++)
- {
- bsBlueColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bsGreenColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bsRedColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- // Draw Gray
- BYTE temp;
- temp = (bsRedColor+bsGreenColor/2+bsBlueColor)/3;
- bsBlueColor = temp>0 ? (temp) : 0;
- bsGreenColor = temp>0 ? (temp<<1) : 0;
- bsRedColor = temp>0 ? (temp) : 0;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX) + i] = (bsBlueColor<<m_stBitsMaskInfo.bBShift) | (bsGreenColor<<m_stBitsMaskInfo.bGShift) | (bsRedColor<<m_stBitsMaskInfo.bRShift);
- }
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- for(WORD i = 0 ; i < (sizeof(WORD)*(rc.right-nLastWidth));i++)
- {
- bsBlueColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bsGreenColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bsRedColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- // Draw Gray
- BYTE temp;
- temp = (bsRedColor+bsGreenColor/2+bsBlueColor)/3;
- bsBlueColor = temp>0 ? (temp) : 0;
- bsGreenColor = temp>0 ? (temp<<1) : 0;
- bsRedColor = temp>0 ? (temp) : 0;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX) + i] = (bsBlueColor<<m_stBitsMaskInfo.bBShift) | (bsGreenColor<<m_stBitsMaskInfo.bGShift) | (bsRedColor<<m_stBitsMaskInfo.bRShift);
- }
- // memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*(rc.right-nLastWidth));
- x += nCntCopyWord;
- }
- else
- {
- for(WORD i = 0 ; i < (sizeof(WORD)*nCntCopyWord/2);i++)
- {
- bsBlueColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bsGreenColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bsRedColor = (BYTE)((pwSrc[x+i] & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- // Draw Gray
- BYTE temp;
- temp = (bsRedColor+bsGreenColor/2+bsBlueColor)/3;
- bsBlueColor = temp>0 ? (temp) : 0;
- bsGreenColor = temp>0 ? (temp<<1) : 0;
- bsRedColor = temp>0 ? (temp) : 0;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX) + i] = (bsBlueColor<<m_stBitsMaskInfo.bBShift) | (bsGreenColor<<m_stBitsMaskInfo.bGShift) | (bsRedColor<<m_stBitsMaskInfo.bRShift);
- }
- x += nCntCopyWord;
- }
- }
- }
- else if ( pwSrc[x] == 0xC2 || pwSrc[x] == 0xC3 )
- {
- WORD wDyingKind, wChooseColor;
- wDyingKind = pwSrc[x];
- switch ( wDyingKind )
- {
- case 0xC2:
- wChooseColor = wChooseColor1;
- break;
- case 0xC3:
- wChooseColor = wChooseColor2;
- break;
- }
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rc.left > nCurrWidth || rc.right < nLastWidth )
- {
- x += nCntCopyWord;
- }
- else
- {
- // rc.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth < rc.left && rc.left <= nCurrWidth )
- {
- x += (rc.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < nCurrWidth-rc.left; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- // Draw Gray
- BYTE temp;
- temp = (bRedWantedColor+bGreenWantedColor/2+bBlueWantedColor)/3;
- bBlueWantedColor = temp>0 ? (temp) : 0;
- bGreenWantedColor = temp>0 ? (temp<<1) : 0;
- bRedWantedColor = temp>0 ? (temp) : 0;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- for ( INT nCheck = 0; nCheck < rc.right-nLastWidth; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- // Draw Gray
- BYTE temp;
- temp = (bRedWantedColor+bGreenWantedColor/2+bBlueWantedColor)/3;
- bBlueWantedColor = temp>0 ? (temp) : 0;
- bGreenWantedColor = temp>0 ? (temp<<1) : 0;
- bRedWantedColor = temp>0 ? (temp) : 0;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- else
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
-
- // Draw Gray
- BYTE temp;
- temp = (bRedWantedColor+bGreenWantedColor/2+bBlueWantedColor)/3;
- bBlueWantedColor = temp>0 ? (temp) : 0;
- bGreenWantedColor = temp>0 ? (temp<<1) : 0;
- bRedWantedColor = temp>0 ? (temp) : 0;
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- }
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- }
- }
- m_pddsBackBuffer->Unlock(NULL);
- return TRUE;
- }
- return FALSE;
- }
- VOID CWHDXGraphicWindow::DrawWithGrayBackBuffer()
- {
- DDSURFACEDESC2 ddsd;
- RECT rc = {0, 0, 800, 500};
- if ( m_pddsBackBuffer == NULL ) return;
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.lpSurface = NULL;
-
- m_pddsBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
- if ( !ddsd.lpSurface ) return;
- WORD *pwdSrc, *pwdDst;
- BYTE bsBlueColor, bsGreenColor, bsRedColor;
- pwdDst = (WORD*)ddsd.lpSurface;
- pwdSrc = (WORD*)ddsd.lpSurface;
- for ( INT y=rc.top ; y < rc.bottom ; y++ )
- {
- for ( INT x=rc.left ; x < rc.right ; x++ )
- {
- bsBlueColor = (BYTE)((pwdSrc[y * (ddsd.lPitch >> 1) + x] & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bsGreenColor = (BYTE)((pwdSrc[y * (ddsd.lPitch >> 1) + x] & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bsRedColor = (BYTE)((pwdSrc[y * (ddsd.lPitch >> 1) + x] & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- // Draw Gray
- BYTE temp;
- temp = (bsRedColor+bsGreenColor/2+bsBlueColor)/3;
- bsBlueColor = temp>0 ? (temp) : 0;
- bsGreenColor = temp>0 ? (temp<<1) : 0;
- bsRedColor = temp>0 ? (temp) : 0;
- pwdDst[y * (ddsd.lPitch >> 1) + x] = (bsBlueColor<<m_stBitsMaskInfo.bBShift) | (bsGreenColor<<m_stBitsMaskInfo.bGShift) | (bsRedColor<<m_stBitsMaskInfo.bRShift);
- }
- }
- m_pddsBackBuffer->Unlock(NULL);
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::DrawWithImageForCompClipRgnToMem()
- 累己磊 :
- 累己老 :
- 格利 : 拘绵等 家胶 捞固瘤狼 盔窍绰 荤捞令 拘绵阑 钱篮 惑怕肺 傈崔罐篮 皋葛府(pwDst)俊 墨乔茄促.
- 涝仿 : INT nStartX
- INT nStartY
- INT nWantedXSize
- INT nWantedYSize
- WORD* pwSrc
- WORD wClipWidth
- WORD wClipHeight
- WORD wChooseColor1
- WORD wChooseColor2
- 免仿 : BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BOOL CWHDXGraphicWindow::DrawWithImageForCompColorToMem(RECT rcWanted, WORD* pwSrc, WORD wColor, WORD* pwDst)
- {
- if ( rcWanted.left < 0 || rcWanted.right < 0 || rcWanted.top < 0 || rcWanted.bottom < 0 ||
- rcWanted.right - rcWanted.left < 0 || rcWanted.bottom - rcWanted.top < 0 || pwDst == NULL )
- return FALSE;
- INT nWidthStart = 0;
- INT nWidthEnd = 0;
- INT nCurrWidth = 0;
- INT nCntCopyWord = 0;
- INT nYCnt = 0;
- INT nLastWidth = 0;
- // y绵 努府俏.
- for ( nYCnt=0 ; nYCnt < rcWanted.top ; nYCnt++ )
- {
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- }
- INT nNewCurrWidth = 0;
- FLOAT rBlueRate, rGreenRate, rRedRate;
- BYTE bRedSrc, bGreenSrc, bBlueSrc;
- BYTE bRedStateColor, bGreenStateColor, bBlueStateColor;
- WORD wPixel;
- // y绵俊 措秦辑 角力肺 风俏矫懦 Count父阑 沥茄促.
- for ( nYCnt=rcWanted.top ; nYCnt < rcWanted.bottom ; nYCnt++ )
- {
- // 茄扼牢狼 辨捞甫 掘绢柯促.(窜困绰 况靛)
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- // 扼牢狼 辨捞父怒 拳搁俊 谎妨霖促.
- for ( INT x = nWidthStart; x < nWidthEnd ; )
- {
- if ( pwSrc[x] == 0xC0 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- // rcWanted.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth <= rcWanted.left && nCurrWidth >= rcWanted.right )
- {
- memset(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], 0, sizeof(WORD)*(rcWanted.right-rcWanted.left));
- nNewCurrWidth += rcWanted.right-rcWanted.left;
- }
- else if ( nLastWidth < rcWanted.left && nCurrWidth > rcWanted.left )
- {
- memset(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], 0, sizeof(WORD)*(nCurrWidth-rcWanted.left));
- nNewCurrWidth += nCurrWidth-rcWanted.left;
- }
- else if ( nLastWidth >= rcWanted.left && nCurrWidth <= rcWanted.right )
- {
- memset(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], 0, sizeof(WORD)*(nCntCopyWord));
- nNewCurrWidth += nCntCopyWord;
- }
- // rcWanted.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth < rcWanted.right && nCurrWidth > rcWanted.right )
- {
- memset(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], 0, sizeof(WORD)*(rcWanted.right-nLastWidth));
- nNewCurrWidth += rcWanted.right-nLastWidth;
- }
- }
- else if ( pwSrc[x] == 0xC1 || pwSrc[x] == 0xC2 || pwSrc[x] == 0xC3 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rcWanted.left > nCurrWidth || rcWanted.right < nLastWidth )
- {
- x += nCntCopyWord;
- }
- else
- {
- // rcWanted.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth <= rcWanted.left && nCurrWidth >= rcWanted.right )
- {
- x += (rcWanted.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < rcWanted.right-rcWanted.left; nCheck++ )
- {
- wPixel = wColor;
- bBlueStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- if ( !wColor )
- {
- BYTE bTemp = (BYTE)(bBlueSrc+(bGreenSrc>>1)+bRedSrc)/3;
- if ( bTemp > 31 ) bTemp = 31;
- bBlueStateColor = bRedStateColor = bTemp;
- bGreenStateColor = bTemp<<1;
- }
- else
- {
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- rRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueStateColor = (BYTE)((FLOAT)bBlueStateColor *rBlueRate );
- bGreenStateColor = (BYTE)((FLOAT)bGreenStateColor*rGreenRate);
- bRedStateColor = (BYTE)((FLOAT)bRedStateColor *rRedRate );
- if ( bBlueStateColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueStateColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenStateColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenStateColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedStateColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedStateColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- }
- if ( !bRedStateColor && !bGreenStateColor && !bBlueStateColor ) bRedStateColor = bGreenStateColor = bBlueStateColor = 1;
- pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + (nNewCurrWidth+nCheck)] = ((bRedStateColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenStateColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueStateColor <<m_stBitsMaskInfo.bBShift));
- }
- nNewCurrWidth += rcWanted.right-rcWanted.left;
- x += (nCurrWidth-rcWanted.left);
- }
- else if ( nLastWidth < rcWanted.left && nCurrWidth > rcWanted.left )
- {
- x += (rcWanted.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < nCurrWidth-rcWanted.left; nCheck++ )
- {
- wPixel = wColor;
- bBlueStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- if ( !wColor )
- {
- BYTE bTemp = (BYTE)(bBlueSrc+(bGreenSrc>>1)+bRedSrc)/3;
- if ( bTemp > 31 ) bTemp = 31;
- bBlueStateColor = bRedStateColor = bTemp;
- bGreenStateColor = bTemp<<1;
- }
- else
- {
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- rRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueStateColor = (BYTE)((FLOAT)bBlueStateColor *rBlueRate );
- bGreenStateColor = (BYTE)((FLOAT)bGreenStateColor*rGreenRate);
- bRedStateColor = (BYTE)((FLOAT)bRedStateColor *rRedRate );
- if ( bBlueStateColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueStateColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenStateColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenStateColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedStateColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedStateColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- }
- if ( !bRedStateColor && !bGreenStateColor && !bBlueStateColor ) bRedStateColor = bGreenStateColor = bBlueStateColor = 1;
- pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + (nNewCurrWidth+nCheck)] = ((bRedStateColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenStateColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueStateColor <<m_stBitsMaskInfo.bBShift));
- }
- nNewCurrWidth += nCurrWidth-rcWanted.left;
- x += (nCurrWidth-rcWanted.left);
- }
- else if ( nLastWidth >= rcWanted.left && nCurrWidth <= rcWanted.right )
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- wPixel = wColor;
- bBlueStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- if ( !wColor )
- {
- BYTE bTemp = (BYTE)(bBlueSrc+(bGreenSrc>>1)+bRedSrc)/3;
- if ( bTemp > 31 ) bTemp = 31;
- bBlueStateColor = bRedStateColor = bTemp;
- bGreenStateColor = bTemp<<1;
- }
- else
- {
- if ( nCheck == 17 )
- int b = 0;
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- rRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueStateColor = (BYTE)((FLOAT)bBlueStateColor *rBlueRate );
- bGreenStateColor = (BYTE)((FLOAT)bGreenStateColor*rGreenRate);
- bRedStateColor = (BYTE)((FLOAT)bRedStateColor *rRedRate );
- if ( bBlueStateColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueStateColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenStateColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenStateColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedStateColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedStateColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- }
- if ( !bRedStateColor && !bGreenStateColor && !bBlueStateColor ) bRedStateColor = bGreenStateColor = bBlueStateColor = 1;
- pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + (nNewCurrWidth+nCheck)] = ((bRedStateColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenStateColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueStateColor <<m_stBitsMaskInfo.bBShift));
- }
- nNewCurrWidth += nCntCopyWord;
- x += nCntCopyWord;
- }
- // rcWanted.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth < rcWanted.right && nCurrWidth > rcWanted.right )
- {
- for ( INT nCheck = 0; nCheck < rcWanted.right-nLastWidth; nCheck++ )
- {
- wPixel = wColor;
- bBlueStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedStateColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- if ( !wColor )
- {
- BYTE bTemp = (BYTE)(bBlueSrc+(bGreenSrc>>1)+bRedSrc)/3;
- if ( bTemp > 31 ) bTemp = 31;
- bBlueStateColor = bRedStateColor = bTemp;
- bGreenStateColor = bTemp<<1;
- }
- else
- {
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- rRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueStateColor = (BYTE)((FLOAT)bBlueStateColor *rBlueRate );
- bGreenStateColor = (BYTE)((FLOAT)bGreenStateColor*rGreenRate);
- bRedStateColor = (BYTE)((FLOAT)bRedStateColor *rRedRate );
- if ( bBlueStateColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueStateColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenStateColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenStateColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedStateColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedStateColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- }
- if ( !bRedStateColor && !bGreenStateColor && !bBlueStateColor ) bRedStateColor = bGreenStateColor = bBlueStateColor = 1;
- pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + (nNewCurrWidth+nCheck)] = ((bRedStateColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenStateColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueStateColor <<m_stBitsMaskInfo.bBShift));
- }
- nNewCurrWidth += rcWanted.right-nLastWidth;
- x += nCntCopyWord;
- }
- else
- {
- x += nCntCopyWord;
- }
- }
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- nNewCurrWidth = 0;
- }
- return TRUE;
- }
- BOOL CWHDXGraphicWindow::DrawWithImageForCompToMem(RECT rcWanted, WORD* pwSrc, WORD wChooseColor1, WORD wChooseColor2, WORD* pwDst)
- {
- if ( rcWanted.left < 0 || rcWanted.right < 0 || rcWanted.top < 0 || rcWanted.bottom < 0 ||
- rcWanted.right - rcWanted.left < 0 || rcWanted.bottom - rcWanted.top < 0 || pwDst == NULL )
- return FALSE;
- INT nWidthStart = 0;
- INT nWidthEnd = 0;
- INT nCurrWidth = 0;
- INT nCntCopyWord = 0;
- INT nYCnt = 0;
- INT nLastWidth = 0;
- // y绵 努府俏.
- for ( nYCnt=0 ; nYCnt < rcWanted.top ; nYCnt++ )
- {
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- }
- INT nNewCurrWidth = 0;
- FLOAT rBlueRate, rGreenRate, bRedRate;
- BYTE bRedSrc, bGreenSrc, bBlueSrc;
- BYTE bRedWantedColor, bGreenWantedColor, bBlueWantedColor;
- WORD wPixel;
- // y绵俊 措秦辑 角力肺 风俏矫懦 Count父阑 沥茄促.
- for ( nYCnt=rcWanted.top ; nYCnt < rcWanted.bottom ; nYCnt++ )
- {
- // 茄扼牢狼 辨捞甫 掘绢柯促.(窜困绰 况靛)
- nWidthEnd += pwSrc[nWidthStart];
- nWidthStart++;
- // 扼牢狼 辨捞父怒 拳搁俊 谎妨霖促.
- for ( INT x = nWidthStart; x < nWidthEnd ; )
- {
- if ( pwSrc[x] == 0xC0 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- // rcWanted.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth <= rcWanted.left && nCurrWidth >= rcWanted.right )
- {
- memset(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], 0, sizeof(WORD)*(rcWanted.right-rcWanted.left));
- nNewCurrWidth += rcWanted.right-rcWanted.left;
- }
- else if ( nLastWidth < rcWanted.left && nCurrWidth > rcWanted.left )
- {
- memset(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], 0, sizeof(WORD)*(nCurrWidth-rcWanted.left));
- nNewCurrWidth += nCurrWidth-rcWanted.left;
- }
- else if ( nLastWidth >= rcWanted.left && nCurrWidth <= rcWanted.right )
- {
- memset(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], 0, sizeof(WORD)*(nCntCopyWord));
- nNewCurrWidth += nCntCopyWord;
- }
- // rcWanted.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth < rcWanted.right && nCurrWidth > rcWanted.right )
- {
- memset(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], 0, sizeof(WORD)*(rcWanted.right-nLastWidth));
- nNewCurrWidth += rcWanted.right-nLastWidth;
- }
- }
- else if ( pwSrc[x] == 0xC1 )
- {
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rcWanted.left > nCurrWidth || rcWanted.right < nLastWidth )
- {
- x += nCntCopyWord;
- }
- else
- {
- // rcWanted.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth <= rcWanted.left && nCurrWidth >= rcWanted.right )
- {
- x += (rcWanted.left-nLastWidth);
- memcpy(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], &pwSrc[x], sizeof(WORD)*(rcWanted.right-rcWanted.left));
- nNewCurrWidth += rcWanted.right-rcWanted.left;
- x += (nCurrWidth-rcWanted.left);
- }
- else if ( nLastWidth < rcWanted.left && nCurrWidth > rcWanted.left )
- {
- x += (rcWanted.left-nLastWidth);
- memcpy(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], &pwSrc[x], sizeof(WORD)*(nCurrWidth-rcWanted.left));
- nNewCurrWidth += nCurrWidth-rcWanted.left;
- x += (nCurrWidth-rcWanted.left);
- }
- else if ( nLastWidth >= rcWanted.left && nCurrWidth <= rcWanted.right )
- {
- memcpy(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], &pwSrc[x], sizeof(WORD)*nCntCopyWord);
- nNewCurrWidth += nCntCopyWord;
- x += nCntCopyWord;
- }
- // rcWanted.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth < rcWanted.right && nCurrWidth > rcWanted.right )
- {
- memcpy(&pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + nNewCurrWidth], &pwSrc[x], sizeof(WORD)*(rcWanted.right-nLastWidth));
- nNewCurrWidth += rcWanted.right-nLastWidth;
- x += nCntCopyWord;
- }
- else
- {
- x += nCntCopyWord;
- }
- }
- }
- else if ( pwSrc[x] == 0xC2 || pwSrc[x] == 0xC3 )
- {
- WORD wDyingKind, wChooseColor;
- wDyingKind = pwSrc[x];
- switch ( wDyingKind )
- {
- case 0xC2:
- wChooseColor = wChooseColor1;
- break;
- case 0xC3:
- wChooseColor = wChooseColor2;
- break;
- }
- x++;
- nCntCopyWord = pwSrc[x];
- x++;
- nLastWidth = nCurrWidth;
- nCurrWidth += nCntCopyWord;
- if ( rcWanted.left > nCurrWidth || rcWanted.right < nLastWidth )
- {
- x += nCntCopyWord;
- }
- else
- {
- // rcWanted.left痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- if ( nLastWidth <= rcWanted.left && nCurrWidth >= rcWanted.right )
- {
- x += (rcWanted.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < rcWanted.right-rcWanted.left; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + (nNewCurrWidth+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- nNewCurrWidth += rcWanted.right-rcWanted.left;
- x += (nCurrWidth-rcWanted.left);
- }
- else if ( nLastWidth < rcWanted.left && nCurrWidth > rcWanted.left )
- {
- x += (rcWanted.left-nLastWidth);
- for ( INT nCheck = 0; nCheck < nCurrWidth-rcWanted.left; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + (nNewCurrWidth+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- nNewCurrWidth += nCurrWidth-rcWanted.left;
- x += (nCurrWidth-rcWanted.left);
- }
- else if ( nLastWidth >= rcWanted.left && nCurrWidth <= rcWanted.right )
- {
- for ( INT nCheck = 0; nCheck < nCntCopyWord; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + (nNewCurrWidth+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- nNewCurrWidth += nCntCopyWord;
- x += nCntCopyWord;
- }
- // rcWanted.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth < rcWanted.right && nCurrWidth > rcWanted.right )
- {
- for ( INT nCheck = 0; nCheck < rcWanted.right-nLastWidth; nCheck++ )
- {
- wPixel = wChooseColor;
- bBlueWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedWantedColor = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- wPixel = pwSrc[x+nCheck];
- bBlueSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueWantedColor = (BYTE)(((FLOAT)bBlueWantedColor*rBlueRate));
- bGreenWantedColor = (BYTE)(((FLOAT)bGreenWantedColor*rGreenRate));
- bRedWantedColor = (BYTE)(((FLOAT)bRedWantedColor*bRedRate));
- if ( bBlueWantedColor > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueWantedColor = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenWantedColor > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenWantedColor = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedWantedColor > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedWantedColor = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- pwDst[((nYCnt-rcWanted.top) * (rcWanted.right-rcWanted.left)) + (nNewCurrWidth+nCheck)] = ((bRedWantedColor <<m_stBitsMaskInfo.bRShift) |
- (bGreenWantedColor<<m_stBitsMaskInfo.bGShift) |
- (bBlueWantedColor <<m_stBitsMaskInfo.bBShift));
- }
- nNewCurrWidth += rcWanted.right-nLastWidth;
- x += nCntCopyWord;
- }
- else
- {
- x += nCntCopyWord;
- }
- }
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;
- nWidthStart = nWidthEnd;
- nCurrWidth = 0;
- nNewCurrWidth = 0;
- }
- return TRUE;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::DrawWithABlendForIntersectCompData()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : INT nX : 归滚欺惑狼 弊覆矫累困摹.
- INT nY
- INT nSrcXSize : 盔夯弊覆狼 荤捞令.
- INT nSrcYSize
- WORD* pwSrc : 盔夯弊覆狼 单捞鸥.
- INT nDstXSize : 鸥百弊覆狼 荤捞令.
- INT nDstYSize
- WORD* pwDst : 鸥百弊覆狼 单捞鸥.
- WORD wSrcChooseColor1 : 盔夯弊覆狼 堪祸 捞固瘤1 拿矾.
- WORD wSrcChooseColor2
- WORD wDstChooseColor1 : 鸥百弊覆狼 堪祸 捞固瘤1 拿矾.
- WORD wDstChooseColor2
- 免仿 : BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BOOL CWHDXGraphicWindow::DrawWithABlendForIntersectCompData(INT nSrcX, INT nSrcY,
- INT nSrcXSize, INT nSrcYSize, WORD* pwSrc,
- INT nDstX, INT nDstY,
- INT nDstXSize, INT nDstYSize, WORD* pwDst,
- WORD wClipWidth, WORD wClipHeight,
- BYTE bOpa, BOOL bFocused,
- WORD wSrcChooseColor1, WORD wSrcChooseColor2,
- WORD wDstChooseColor1, WORD wDstChooseColor2,
- WORD wSrcColor, WORD wDstColor)
- {
- DDSURFACEDESC2 ddsd;
- RECT rcSrc, rcDst;
- RECT rcSrcIntersect = { 0, 0, 0, 0 };
- RECT rcDstIntersect = { 0, 0, 0, 0 };
- WORD* pwdDst = NULL;
- INT nSrcWidth = nSrcXSize;
- INT nSrcHeight = nSrcYSize;
- INT nXSrcOffset = 0;
- INT nYSrcOffset = 0;
- INT nDstWidth = nDstXSize;
- INT nDstHeight = nDstYSize;
- INT nXDstOffset = 0;
- INT nYDstOffset = 0;
- INT nEndX = wClipWidth -1;
- INT nEndY = wClipHeight-1;
- INT nStartX = 0;
- INT nStartY = 0;
- WORD* pwDstSave = NULL;
- WORD* pwSrcSave = NULL;
- if ( m_pddsBackBuffer != NULL )
- {
- // Source狼 拳搁努府俏茄 康开.
- if ( nSrcX < nStartX )
- {
- nXSrcOffset = nStartX - nSrcX;
- nSrcWidth = nSrcXSize - nXSrcOffset;
- }
- if ( (nSrcX+nSrcXSize-1) > nEndX )
- nSrcWidth = nEndX - nSrcX - nXSrcOffset + 1;
- if ( nSrcY < nStartY )
- {
- nYSrcOffset = nStartY - nSrcY;
- nSrcHeight = nSrcYSize - nYSrcOffset;
- }
- if ( (nSrcY+nSrcYSize-1) > nEndY )
- nSrcHeight = nEndY - nSrcY - nYSrcOffset + 1;
- if ( (nSrcWidth > 0) && (nSrcHeight > 0) )
- {
- // Source康开狼 汲沥.
- rcSrc.left = nXSrcOffset;
- rcSrc.right = nXSrcOffset+nSrcWidth;
- rcSrc.top = nYSrcOffset;
- rcSrc.bottom = nYSrcOffset+nSrcHeight;
- // Destination狼 拳搁努府俏茄 康开.
- if ( nDstX < nStartX )
- {
- nXDstOffset = nStartX - nDstX;
- nDstWidth = nDstXSize - nXDstOffset;
- }
- if ( (nDstX+nDstXSize-1) > nEndX )
- nDstWidth = nEndX - nDstX - nXDstOffset + 1;
- if ( nDstY < nStartY )
- {
- nYDstOffset = nStartY - nDstY;
- nDstHeight = nDstYSize - nYDstOffset;
- }
- if ( (nDstY+nDstYSize-1) > nEndY )
- nDstHeight = nEndY - nDstY - nYDstOffset + 1;
- if ( (nDstWidth > 0) && (nDstHeight > 0) )
- {
- // Destination康开狼 汲沥.
- rcDst.left = nXDstOffset;
- rcDst.right = nXDstOffset+nDstWidth;
- rcDst.top = nYDstOffset;
- rcDst.bottom = nYDstOffset+nDstHeight;
- // 滴捞固瘤狼 般摹绰 康开阑 备茄促.
- RECT rcTemp;
- // 家胶康开俊 惑措利牢 单胶飘康开阑 备茄促.
- rcTemp.left = rcDst.left + (nDstX-nSrcX);
- rcTemp.top = rcDst.top + (nDstY-nSrcY);
- rcTemp.right = rcDst.right + (nDstX-nSrcX);
- rcTemp.bottom = rcDst.bottom + (nDstY-nSrcY);
- // 家胶 泛飘康开阑 扁霖栏肺 茄 滴 荤阿屈狼 背瞒荤阿屈阑 备茄促.
- IntersectRect(&rcSrcIntersect, &rcSrc, &rcTemp);
- // 单胶飘康开俊 惑措利牢 家胶康开阑 备茄促.
- rcTemp.left = rcSrc.left + (nSrcX-nDstX);
- rcTemp.top = rcSrc.top + (nSrcY-nDstY);
- rcTemp.right = rcSrc.right + (nSrcX-nDstX);
- rcTemp.bottom = rcSrc.bottom + (nSrcY-nDstY);
- // 单胶飘 泛飘康开阑 扁霖栏肺 茄 滴 荤阿屈狼 背瞒荤阿屈阑 备茄促.
- IntersectRect(&rcDstIntersect, &rcTemp, &rcDst);
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.lpSurface = NULL;
- m_pddsBackBuffer->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
- if ( !ddsd.lpSurface ) return FALSE;
- pwdDst = (WORD*)ddsd.lpSurface;
- pwSrcSave = new WORD[(rcSrcIntersect.right-rcSrcIntersect.left)*(rcSrcIntersect.bottom-rcSrcIntersect.top)];
- pwDstSave = new WORD[(rcDstIntersect.right-rcDstIntersect.left)*(rcDstIntersect.bottom-rcDstIntersect.top)];
- if ( wSrcColor == 0XFFFF && wDstColor == 0XFFFF )
- {
- DrawWithImageForCompToMem(rcSrcIntersect, (WORD*)pwSrc, wSrcChooseColor1, wSrcChooseColor2, pwSrcSave);
- DrawWithImageForCompToMem(rcDstIntersect, (WORD*)pwDst, wDstChooseColor1, wDstChooseColor2, pwDstSave);
- }
- else if ( wSrcColor != 0XFFFF && wDstColor == 0XFFFF )
- {
- DrawWithImageForCompColorToMem(rcSrcIntersect, (WORD*)pwSrc, wSrcColor, pwSrcSave);
- DrawWithImageForCompToMem(rcDstIntersect, (WORD*)pwDst, wDstChooseColor1, wDstChooseColor2, pwDstSave);
- }
- else if ( wSrcColor == 0XFFFF && wDstColor != 0XFFFF )
- {
- DrawWithImageForCompToMem(rcSrcIntersect, (WORD*)pwSrc, wSrcChooseColor1, wSrcChooseColor2, pwSrcSave);
- DrawWithImageForCompColorToMem(rcDstIntersect, (WORD*)pwDst, wDstColor, pwDstSave);
- }
- else
- {
- DrawWithImageForCompColorToMem(rcSrcIntersect, (WORD*)pwSrc, wSrcColor, pwSrcSave);
- DrawWithImageForCompColorToMem(rcDstIntersect, (WORD*)pwDst, wDstColor, pwDstSave);
- }
- BYTE bRedDst, bGreenDst, bBlueDst;
- BYTE bRedSrc, bGreenSrc, bBlueSrc;
- WORD wSrcPixel, wDstPixel;
- FLOAT rBlueRate, rGreenRate, bRedRate;
- for ( INT nYCnt = 0; nYCnt < rcSrcIntersect.bottom - rcSrcIntersect.top; nYCnt++ )
- for ( INT nXCnt = 0; nXCnt < rcSrcIntersect.right - rcSrcIntersect.left; nXCnt++ )
- {
- wSrcPixel = pwSrcSave[nYCnt*(rcSrcIntersect.right - rcSrcIntersect.left) + nXCnt];
- wDstPixel = pwDstSave[nYCnt*(rcDstIntersect.right - rcDstIntersect.left) + nXCnt];
- if ( wSrcPixel != 0 && wDstPixel != 0 )
- {
- bBlueSrc = (BYTE)((wSrcPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenSrc = (BYTE)((wSrcPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedSrc = (BYTE)((wSrcPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- if ( bFocused )
- {
- rBlueRate = (FLOAT)((FLOAT)bBlueSrc / (FLOAT)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift));
- rGreenRate = (FLOAT)((FLOAT)bGreenSrc / (FLOAT)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift));
- bRedRate = (FLOAT)((FLOAT)bRedSrc / (FLOAT)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift));
- bBlueSrc = (BYTE)((FLOAT)bBlueSrc + ((FLOAT)bBlueSrc*rBlueRate));
- bGreenSrc = (BYTE)((FLOAT)bGreenSrc + ((FLOAT)bGreenSrc*rGreenRate));
- bRedSrc = (BYTE)((FLOAT)bRedSrc + ((FLOAT)bRedSrc*bRedRate));
- if ( bBlueSrc > (m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift) )
- bBlueSrc = (BYTE)(m_stBitsMaskInfo.dwBMask>>m_stBitsMaskInfo.bBShift);
- if ( bGreenSrc > (m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift) )
- bGreenSrc = (BYTE)(m_stBitsMaskInfo.dwGMask>>m_stBitsMaskInfo.bGShift);
- if ( bRedSrc > (m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift) )
- bRedSrc = (BYTE)(m_stBitsMaskInfo.dwRMask>>m_stBitsMaskInfo.bRShift);
- // 器目胶啊 灯阑锭 Opacity蔼阑 臭咯霖促.
- bOpa = 40;
- }
- bBlueDst = (BYTE)((wDstPixel & m_stBitsMaskInfo.dwBMask) >> m_stBitsMaskInfo.bBShift);
- bGreenDst = (BYTE)((wDstPixel & m_stBitsMaskInfo.dwGMask) >> m_stBitsMaskInfo.bGShift);
- bRedDst = (BYTE)((wDstPixel & m_stBitsMaskInfo.dwRMask) >> m_stBitsMaskInfo.bRShift);
- bBlueDst = (BYTE)((bOpa*(bBlueDst -bBlueSrc )+100*bBlueSrc ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenSrc)+100*bGreenSrc) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedSrc )+100*bRedSrc ) / 100);
- pwdDst[((nYCnt+nSrcY+rcSrcIntersect.top) * (ddsd.lPitch >> 1)) + (rcSrcIntersect.left+nSrcX+nXCnt)] =
- ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<m_stBitsMaskInfo.bBShift));
- }
- }
- SAFE_DELETE(pwSrcSave);
- SAFE_DELETE(pwDstSave);
- m_pddsBackBuffer->Unlock(NULL);
- return TRUE;
- }
- }
- }
- return FALSE;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::Present()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : LPRECT lprcDest
- LPRECT lprcSrc
- BYTE bCntRgn
- 免仿 : HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HRESULT CWHDXGraphicWindow::Present()
- {
- HRESULT hr;
- if ( NULL == m_pddsFrontBuffer || NULL == m_pddsBackBuffer )
- {
- return E_POINTER;
- }
- while ( TRUE )
- {
- // if ( m_bScreenModeFlag & _DXG_SCREENMODE_WINDOW )
- // {
- // 俊叼飘扩档快 免仿阑 困秦辑 努府欺甫 技泼茄促.
- m_pddsFrontBuffer->SetClipper(m_lpcClipper);
- hr = m_pddsFrontBuffer->Blt(&m_rcWindow, m_pddsBackBuffer, NULL, DDBLT_WAIT, NULL);
- /* }
- else
- {
- hr = m_pddsFrontBuffer->Flip(NULL, DDFLIP_WAIT );
- }
- */
- if(hr == DDERR_SURFACELOST)
- {
- m_pddsFrontBuffer->Restore();
- m_pddsBackBuffer->Restore();
- }
- if(hr != DDERR_WASSTILLDRAWING)
- return hr;
- }
- }
- /******************************************************************************************************************
- 窃荐疙 : RestoreSurfaces()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HRESULT CWHDXGraphicWindow::RestoreSurfaces()
- {
- HRESULT hr;
- if ( !m_pDD )
- return E_FAIL;
- if ( FAILED(hr = m_pDD->RestoreAllSurfaces()) )
- return hr;
- return S_OK;
- }
- /******************************************************************************************************************
- Callback Function
- *******************************************************************************************************************/
- /******************************************************************************************************************
- 窃荐疙 : WINAPI DXGDriverEnumCallbackEx()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : GUID *pGUID
- LPSTR szDesc
- LPSTR szName
- LPVOID pContext
- HMONITOR hm
- 免仿 : static BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- static BOOL WINAPI DXGDriverEnumCallbackEx(GUID *pGUID, LPSTR szDesc, LPSTR szName, LPVOID pContext, HMONITOR hm)
- {
- LPDIRECTDRAW7 pDD = NULL;
- LPDIRECT3D7 pD3D = NULL;
- DXG_ENUM_DEVICEINFO stDXGEnumDeviceInfo;
- HRESULT hr;
- if ( FAILED(hr = DirectDrawCreateEx(pGUID, (VOID**) &pDD, IID_IDirectDraw7, NULL)) )
- {
- MessageBox(NULL, TEXT("[DXGDriverEnumCallbackEx]") TEXT("Can't create DDraw during enumeration!"), "MirDXG", MB_ICONERROR | MB_OK);
- return D3DENUMRET_OK;
- }
- if ( FAILED(hr = pDD->QueryInterface(IID_IDirect3D7, (VOID**) &pD3D)) )
- {
- SAFE_RELEASE(pDD);
- MessageBox(NULL, TEXT("[DXGDriverEnumCallbackEx]") TEXT("Can't query IDirect3D7 during enumeration!"), "MirDXG", MB_ICONERROR | MB_OK);
- return D3DENUMRET_OK;
- }
- ZeroMemory(&stDXGEnumDeviceInfo, sizeof(DXG_ENUM_DEVICEINFO));
- lstrcpyn(stDXGEnumDeviceInfo.szDriverDesc, szDesc, 255);
- stDXGEnumDeviceInfo.ddDriverCaps.dwSize = sizeof(DDCAPS);
- stDXGEnumDeviceInfo.ddHELCaps.dwSize = sizeof(DDCAPS);
- pDD->GetCaps(&stDXGEnumDeviceInfo.ddDriverCaps, &stDXGEnumDeviceInfo.ddHELCaps);
- if ( pGUID )
- {
- stDXGEnumDeviceInfo.guidDriver = (*pGUID);
- stDXGEnumDeviceInfo.pDriverGUID = &stDXGEnumDeviceInfo.guidDriver;
- }
- if ( FAILED(hr = pDD->EnumDisplayModes(0, NULL, &stDXGEnumDeviceInfo, DXGEnumDisplayModeCallback)) )
- {
- MessageBox(NULL, TEXT("[DXGDriverEnumCallbackEx]") TEXT("Can't enumerate displaymode!"), "MirDXG", MB_ICONERROR | MB_OK);
- }
- qsort(stDXGEnumDeviceInfo.pddsdModes, stDXGEnumDeviceInfo.dwNumModes, sizeof(DDSURFACEDESC2), DXGModesSortCallback);
- if ( FAILED(hr = pD3D->EnumDevices(DXG3DDeviceEnumCallback, &stDXGEnumDeviceInfo)) )
- {
- MessageBox(NULL, TEXT("[DXGDriverEnumCallbackEx]") TEXT("Can't enumerate device!"), "MirDXG", MB_ICONERROR | MB_OK);
- }
- SAFE_DELETE(stDXGEnumDeviceInfo.pddsdModes);
- SAFE_RELEASE(pD3D);
- SAFE_RELEASE(pDD);
- return DDENUMRET_OK;
- }
- /******************************************************************************************************************
- 窃荐疙 : WINAPI DXGEnumDisplayModeCallback()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : DDSURFACEDESC2* pddsd
- VOID* pParentInfo
- 免仿 : static HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- static HRESULT WINAPI DXGEnumDisplayModeCallback(DDSURFACEDESC2* pddsd, VOID* pParentInfo)
- {
- DXG_ENUM_DEVICEINFO* pDevice = (DXG_ENUM_DEVICEINFO*) pParentInfo;
- DDSURFACEDESC2* pddsdNewModes = new DDSURFACEDESC2[pDevice->dwNumModes+1];
- memcpy(pddsdNewModes, pDevice->pddsdModes, pDevice->dwNumModes * sizeof(DDSURFACEDESC2));
- SAFE_DELETE(pDevice->pddsdModes);
- pDevice->pddsdModes = pddsdNewModes;
- pDevice->pddsdModes[pDevice->dwNumModes++] = (*pddsd);
- return DDENUMRET_OK;
- }
- /******************************************************************************************************************
- 窃荐疙 : DXGModesSortCallback()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : const VOID* arg1
- const VOID* arg2
- 免仿 : static int
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- static int DXGModesSortCallback(const VOID* arg1, const VOID* arg2)
- {
- DDSURFACEDESC2* p1 = (DDSURFACEDESC2*)arg1;
- DDSURFACEDESC2* p2 = (DDSURFACEDESC2*)arg2;
- if ( p1->dwWidth < p2->dwWidth ) return -1;
- if ( p1->dwWidth > p2->dwWidth ) return +1;
- if ( p1->dwHeight < p2->dwHeight ) return -1;
- if ( p1->dwHeight > p2->dwHeight ) return +1;
- if ( p1->ddpfPixelFormat.dwRGBBitCount < p2->ddpfPixelFormat.dwRGBBitCount ) return -1;
- if ( p1->ddpfPixelFormat.dwRGBBitCount > p2->ddpfPixelFormat.dwRGBBitCount ) return +1;
- return 0;
- }
- /******************************************************************************************************************
- 窃荐疙 : WINAPI DXG3DDeviceEnumCallback()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : TCHAR* szDesc
- TCHAR* szName
- D3DDEVICEDESC7* pDesc
- VOID* pParentInfo
- 免仿 : static HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- static HRESULT WINAPI DXG3DDeviceEnumCallback(TCHAR* szDesc, TCHAR* szName, D3DDEVICEDESC7* pDesc, VOID* pParentInfo)
- {
- DXG_ENUM_DEVICEINFO* pDriverInfo = (DXG_ENUM_DEVICEINFO*)pParentInfo;
- DXG_ENUM_DEVICEINFO* pDeviceInfo = &g_stDXGEnumDeviceInfo[g_bNumDevices];
- ZeroMemory(pDeviceInfo, sizeof(DXG_ENUM_DEVICEINFO));
- pDeviceInfo->f3DHardware = pDesc->dwDevCaps & D3DDEVCAPS_HWRASTERIZATION;
- memcpy(&pDeviceInfo->ddDeviceDesc, pDesc, sizeof(D3DDEVICEDESC7));
- pDeviceInfo->ddDriverCaps = pDriverInfo->ddDriverCaps;
- pDeviceInfo->ddHELCaps = pDriverInfo->ddHELCaps;
- pDeviceInfo->guidDevice = pDesc->deviceGUID;
- pDeviceInfo->pDeviceGUID = &pDeviceInfo->guidDevice;
- pDeviceInfo->pddsdModes = new DDSURFACEDESC2[pDriverInfo->dwNumModes];
- if ( pDriverInfo->pDriverGUID )
- {
- pDeviceInfo->guidDriver = pDriverInfo->guidDriver;
- pDeviceInfo->pDriverGUID = &pDeviceInfo->guidDriver;
- }
- else
- {
- pDeviceInfo->pDriverGUID = NULL;
- }
- lstrcpyn(pDeviceInfo->szDriverDesc, pDriverInfo->szDriverDesc, 255);
- lstrcpyn(pDeviceInfo->szDeviceDesc, szName, 255);
- for ( DWORD dwCnt=0; dwCnt<pDriverInfo->dwNumModes; dwCnt++ )
- {
- DDSURFACEDESC2 ddsdMode = pDriverInfo->pddsdModes[dwCnt];
- DWORD dwRenderDepths = pDeviceInfo->ddDeviceDesc.dwDeviceRenderBitDepth;
- DWORD dwDepth = ddsdMode.ddpfPixelFormat.dwRGBBitCount;
- if ( ( ( dwDepth == 32 ) && ( dwRenderDepths & DDBD_32 ) ) ||
- ( ( dwDepth == 24 ) && ( dwRenderDepths & DDBD_24 ) ) ||
- ( ( dwDepth == 16 ) && ( dwRenderDepths & DDBD_16 ) ) )
- {
- pDeviceInfo->pddsdModes[pDeviceInfo->dwNumModes++] = ddsdMode;
- }
- }
- if ( 0 == pDeviceInfo->dwNumModes )
- return D3DENUMRET_OK;
- g_bNumDevices++;
- if ( NULL != pDeviceInfo->pDriverGUID && FALSE == pDeviceInfo->f3DHardware )
- return D3DENUMRET_OK;
- return D3DENUMRET_OK;
- }
- /******************************************************************************************************************
- 窃荐疙 : WINAPI DXGEnumZBufferFormatsCallback()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : DDPIXELFORMAT* pddpf
- VOID* pContext
- 免仿 : static HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- static HRESULT WINAPI DXGEnumZBufferFormatsCallback(DDPIXELFORMAT* pddpf, VOID* pContext)
- {
- DDPIXELFORMAT* pddpfOut = (DDPIXELFORMAT*) pContext;
- if ( pddpfOut->dwRGBBitCount == pddpf->dwRGBBitCount )
- {
- (*pddpfOut) = (*pddpf);
- return D3DENUMRET_CANCEL;
- }
- return D3DENUMRET_OK;
- }