WHDXGraphic.cpp
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:228k
- /******************************************************************************************************************
-
- 葛碘疙:
-
- 累己磊:
- 累己老:
-
- [老磊][荐沥磊] : 荐沥 郴侩
-
- *******************************************************************************************************************/
- #include "stdafx.h"
- #include "WHEngine.h"
- /******************************************************************************************************************
- CWHDXGraphicWindow Functions
- *******************************************************************************************************************/
- static BYTE g_bNumDevices = 0;
- static DXG_ENUM_DEVICEINFO g_stDXGEnumDeviceInfo[_MAX_DEVICES];
- static INT DXGModesSortCallback(const VOID* arg1, const VOID* arg2);
- static BOOL WINAPI DXGDriverEnumCallbackEx(GUID* pGUID, LPSTR szDesc, LPSTR szName, LPVOID pContext, HMONITOR hm);
- static HRESULT WINAPI DXGEnumDisplayModeCallback(DDSURFACEDESC2* pddsd, VOID* pParentInfo);
- static HRESULT WINAPI DXG3DDeviceEnumCallback(TCHAR* szDesc, TCHAR* szName, D3DDEVICEDESC7* pDesc, VOID* pParentInfo);
- static HRESULT WINAPI DXGEnumZBufferFormatsCallback(DDPIXELFORMAT* pddpf, VOID* pContext);
- CWHDXGraphicWindow* CWHDXGraphicWindow::m_pxDXGWnd = NULL;
- CWHDXGraphicWindow* GetDXGWindowPtr()
- {
- return CWHDXGraphicWindow::m_pxDXGWnd;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::CWHDXGraphicWindow()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : WORD wWidth
- WORD wHeight
- WORD wBpp
- 免仿 :
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- CWHDXGraphicWindow::CWHDXGraphicWindow(WORD wWidth, WORD wHeight, WORD wBpp)
- {
- m_pDD = NULL;
- m_pD3D = NULL;
- m_hDefGameFont = NULL;
- m_pd3dDevice = NULL;
- m_pddsZBuffer = NULL;
- m_pddsFrontBuffer = NULL;
- m_pddsBackBuffer = NULL;
- // 俊叼飘扩档快 免仿阑 困秦辑 努府欺甫 技泼茄促.
- m_lpcClipper = NULL;
- m_stDisplayInfo.wWidth = wWidth;
- m_stDisplayInfo.wHeight = wHeight;
- m_stDisplayInfo.wBPP = wBpp;
- m_bScreenModeFlag = _DXG_SCREENMODE_WINDOW;
- m_bDeviceModeFlag = _DXG_DEVICEMODE_PRIMARY;
- SetRect(&m_rcWindow, 0, 0, 0, 0);
- ZeroMemory(&m_stBitsMaskInfo, sizeof(DXG_MASKINFO));
- m_pxDXGWnd = this;
- m_bIsWindowActive = FALSE;
- m_bIsWindowReady = FALSE;
- m_dwTextureTotal = 0;
- m_dwTextureFree = 0;
- m_dwVideoTotal = 0;
- m_dwVideoFree = 0;
- m_pxDefProcess = NULL;
- }
- VOID CWHDXGraphicWindow::UsedAndFreeMemoryCheck()
- {
- DDSCAPS2 ddsCaps2;
- ZeroMemory(&ddsCaps2, sizeof(ddsCaps2));
- ddsCaps2.dwCaps = DDSCAPS_TEXTURE;
- m_pDD->GetAvailableVidMem(&ddsCaps2, &m_dwTextureTotal, &m_dwTextureFree);
- ZeroMemory(&ddsCaps2, sizeof(ddsCaps2));
- ddsCaps2.dwCaps = DDSCAPS_VIDEOMEMORY;
- m_pDD->GetAvailableVidMem(&ddsCaps2, &m_dwVideoTotal, &m_dwVideoFree);
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::~CWHDXGraphicWindow()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 :
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- CWHDXGraphicWindow::~CWHDXGraphicWindow()
- {
- FreeDXGEnumModeResources();
- DestroyDXGObjects();
- m_pxDefProcess = NULL;
- m_pxDXGWnd = NULL;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::Create()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : LPTSTR lpCaption
- CHAR *pszMenuName
- BYTE bScreenModeFlag
- BYTE bDeviceModeFlag
- 免仿 : BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BOOL CWHDXGraphicWindow::Create(HINSTANCE hInst, LPTSTR lpCaption, CHAR *pszMenuName, CHAR* pszIconName, BYTE bScreenModeFlag, BYTE bDeviceModeFlag)
- {
- DWORD dwStyle;
- if ( !CWHWindow::Create(hInst, lpCaption, pszMenuName, pszIconName) )
- {
- MessageBox(m_hWnd, TEXT("[CWHDXGraphicWindow::Create]") TEXT("Window create failed."), "MirDXG", MB_ICONERROR | MB_OK);
- return FALSE;
- }
- m_bScreenModeFlag = bScreenModeFlag;
- m_bDeviceModeFlag = bDeviceModeFlag;
- if ( m_bScreenModeFlag & _DXG_SCREENMODE_WINDOW )
- {
- dwStyle = GetWindowStyle(m_hWnd);
- dwStyle &= ~WS_POPUP;
- dwStyle |= WS_POPUP;//WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_SYSMENU;
- SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
- }
- else
- {
- dwStyle = GetWindowStyle(m_hWnd);
- dwStyle &= ~dwStyle;
- dwStyle |= WS_POPUP;
- SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
- }
- HRESULT hr;
- if ( hr = SUCCEEDED(DirectDrawEnumerateEx(DXGDriverEnumCallbackEx, NULL,
- DDENUM_ATTACHEDSECONDARYDEVICES | DDENUM_DETACHEDSECONDARYDEVICES | DDENUM_NONDISPLAYDEVICES)) )
- {
- if ( hr = SUCCEEDED(CreateDXG()) )
- {
- m_bIsWindowReady = TRUE;
- CreateDefFont();
- return TRUE;
- }
- else
- {
- MessageBox(m_hWnd, TEXT("[CWHDXGraphicWindow::Create]") TEXT("DirectGraphic create failed."), "MirDXG", MB_ICONERROR | MB_OK);
- return FALSE;
- }
- }
- return FALSE;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::MainWndProcDXG()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : HWND hWnd
- UINT uMsg
- WPARAM wParam
- LPARAM lParam
- 免仿 : LRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- LRESULT CWHDXGraphicWindow::MainWndProcDXG(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
- {
- switch (uMsg)
- {
- case WM_SYSKEYDOWN:
- return OnSysKeyDown(wParam, lParam);
- case WM_MOVE:
- return OnMove(wParam, lParam);
- case WM_SIZE:
- return OnSize(wParam, lParam);
- case WM_DESTROY:
- return OnDestroy();
- case WM_SETCURSOR:
- return OnSetCursor();
- // case WM_GETMINMAXINFO:
- // return OnGetMinMaxInfo(wParam, lParam);
- default:
- break;
- }
- return CWHWindow::MainWndProc(hWnd, uMsg, wParam, lParam);
- }
- LRESULT CWHDXGraphicWindow::OnGetMinMaxInfo(WPARAM wParam, LPARAM lParam)
- {
- if ( m_hWnd )
- {
- MINMAXINFO* pMinMax = (MINMAXINFO*) lParam;
- DWORD dwFrameWidth = GetSystemMetrics( SM_CXSIZEFRAME );
- DWORD dwFrameHeight = GetSystemMetrics( SM_CYSIZEFRAME );
- DWORD dwMenuHeight;
- if( GetMenu( m_hWnd ) )
- dwMenuHeight = GetSystemMetrics( SM_CYMENU );
- else
- dwMenuHeight = 0;
- DWORD dwCaptionHeight = GetSystemMetrics( SM_CYCAPTION );
- pMinMax->ptMinTrackSize.x = m_stDisplayInfo.wWidth + dwFrameWidth * 2;
- pMinMax->ptMinTrackSize.y = m_stDisplayInfo.wHeight + dwFrameHeight * 2 +
- dwMenuHeight + dwCaptionHeight;
- pMinMax->ptMaxTrackSize.x = pMinMax->ptMinTrackSize.x;
- pMinMax->ptMaxTrackSize.y = pMinMax->ptMinTrackSize.y;
- }
- return 0L;
- }
- LRESULT CWHDXGraphicWindow::OnSetCursor()
- {
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- return 0L;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::OnSize()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : WPARAM wParam
- LPARAM lParam
- 免仿 : LRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- LRESULT CWHDXGraphicWindow::OnSize(WPARAM wParam, LPARAM lParam)
- {
- if ( SIZE_MAXHIDE == wParam || SIZE_MINIMIZED == wParam )
- m_bIsWindowActive = FALSE;
- else
- m_bIsWindowActive = TRUE;
- UpdateBoundsWnd();
- return 0L;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::OnMove()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : WPARAM wParam
- LPARAM lParam
- 免仿 : LRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- LRESULT CWHDXGraphicWindow::OnMove(WPARAM wParam, LPARAM lParam)
- {
- UpdateBoundsWnd();
- return 0L;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::OnDestroy()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- LRESULT CWHDXGraphicWindow::OnDestroy()
- {
- return CWHWindow::OnDestroy();
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::OnSysKeyDown()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : WPARAM wParam
- LPARAM lParam
- 免仿 : LRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- LRESULT CWHDXGraphicWindow::OnSysKeyDown(WPARAM wParam, LPARAM lParam)
- {
- if ( wParam == VK_RETURN )
- {
- m_bIsWindowReady = FALSE;
- D3DTextr_InvalidateAllTextures();
- D3DWILTextr_InvalidateAllTextures();
- D3DWILTextr_DestroyAllTextures();
- if ( m_bScreenModeFlag & _DXG_SCREENMODE_WINDOW )
- {
- if ( FAILED(ResetDXG(_SCREEN_WIDTH, _SCREEN_HEIGHT, _SCREEN_BPP, _DXG_SCREENMODE_FULLSCREEN, _DXG_DEVICEMODE_PRIMARY|_DXG_DEVICEMODE_D3D)) )
- {
- MessageBox(m_hWnd, TEXT("DirectDraw RESETUP failed!!!") TEXT("The Program will now exit."), TEXT("MirDXG"), MB_ICONERROR | MB_OK);
- }
- }
- else
- {
- if ( FAILED(ResetDXG(_SCREEN_WIDTH, _SCREEN_HEIGHT, _SCREEN_BPP, _DXG_SCREENMODE_WINDOW, _DXG_DEVICEMODE_PRIMARY|_DXG_DEVICEMODE_D3D)) )
- {
- MessageBox(m_hWnd, TEXT("DirectDraw RESETUP failed!!!") TEXT("The Program will now exit."), TEXT("MirDXG"), MB_ICONERROR | MB_OK);
- }
- }
- D3DTextr_RestoreAllTextures(m_pd3dDevice);
- m_bIsWindowReady = TRUE;
- }
- return 0L;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::FindDriverAndDevice()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : DWORD
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BYTE CWHDXGraphicWindow::FindDriverAndDevice()
- {
- BYTE bNum = 0;
- CHAR bCnt;
-
- if ( m_bDeviceModeFlag & _DXG_DEVICEMODE_PRIMARY )
- {
- for ( bCnt = 0; bCnt < g_bNumDevices; bCnt++ )
- {
- if ( !g_stDXGEnumDeviceInfo[bCnt].pDriverGUID )
- {
- if ( g_stDXGEnumDeviceInfo[bCnt].f3DHardware ) return bCnt;
- else bNum = bCnt;
- }
- }
- }
- else
- {
- for ( bCnt = g_bNumDevices-1; bCnt >= 0; bCnt-- )
- {
- // 厚叼坷 墨靛啊 2俺捞惑
- if( g_bNumDevices > 2 )
- {
- if ( g_stDXGEnumDeviceInfo[0].dwNumModes != g_stDXGEnumDeviceInfo[bCnt].dwNumModes )
- {
- if ( g_stDXGEnumDeviceInfo[bCnt].f3DHardware ) return bCnt;
- else
- {
- bNum = bCnt;
- break;
- }
- }
- }
- else
- {
- if ( g_stDXGEnumDeviceInfo[bCnt].f3DHardware ) return bCnt;
- else bNum = bCnt;
- }
- }
- }
- return bNum;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::DestroyDXGObjects()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HRESULT CWHDXGraphicWindow::DestroyDXGObjects()
- {
- HRESULT hr;
- LONG lDDRefCnt = 0L;
- LONG lD3DRefCnt = 0L;
- if ( !(m_bScreenModeFlag & _DXG_SCREENMODE_WINDOW) )
- {
- if ( FAILED(hr = m_pDD->RestoreDisplayMode()) )
- return E_FAIL;
- }
- if ( m_pDD )
- {
- if ( FAILED(hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL)) )
- return E_FAIL;
- }
- if ( m_pd3dDevice )
- {
- if ( 0 < ( lD3DRefCnt = m_pd3dDevice->Release() ) )
- return E_FAIL;
- }
- m_pd3dDevice = NULL;
- SAFE_RELEASE(m_pddsBackBuffer);
- SAFE_RELEASE(m_pddsFrontBuffer);
- SAFE_RELEASE(m_pddsZBuffer);
- // 俊叼飘扩档快 免仿阑 困秦辑 努府欺甫 技泼茄促.
- SAFE_RELEASE(m_lpcClipper);
- SAFE_RELEASE(m_pD3D);
- if ( m_pDD )
- {
- if ( 0 < ( lDDRefCnt = m_pDD->Release() ) )
- INT nAAAAAA = 0;
- // return E_FAIL;
- }
- m_pDD = NULL;
- if ( m_hDefGameFont != NULL )
- {
- DeleteObject(m_hDefGameFont);
- m_hDefGameFont = NULL;
- }
- return S_OK;
- // return ( lDDRefCnt==0 && lD3DRefCnt==0 ) ? S_OK : E_FAIL;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::FreeDXGEnumModeResources()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : VOID
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- VOID CWHDXGraphicWindow::FreeDXGEnumModeResources()
- {
- for ( BYTE bCnt = 0; bCnt < g_bNumDevices; bCnt++ )
- {
- SAFE_DELETE( g_stDXGEnumDeviceInfo[bCnt].pddsdModes );
- }
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::CreateDXG()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HRESULT CWHDXGraphicWindow::CreateDXG()
- {
- HRESULT hr;
- BYTE bSelecedDevice = FindDriverAndDevice();
- if ( SUCCEEDED(hr = DirectDrawCreateEx(g_stDXGEnumDeviceInfo[bSelecedDevice].pDriverGUID, (VOID**)&m_pDD, IID_IDirectDraw7, NULL)) )
- {
- if ( m_bScreenModeFlag & _DXG_SCREENMODE_WINDOW )
- {
- if ( FAILED(hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL)) )
- return E_FAIL;
- }
- else
- {
- if ( FAILED(hr = m_pDD->SetCooperativeLevel(m_hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT)) )
- return E_FAIL;
- if ( FAILED(hr = m_pDD->SetDisplayMode(m_stDisplayInfo.wWidth, m_stDisplayInfo.wHeight, m_stDisplayInfo.wBPP, 0, 0)) )
- return E_FAIL;
- }
- if ( FAILED(hr == CreatePrimarySurface()) )
- {
- MessageBox(m_hWnd, TEXT("[CWHDXGraphicWindow::CreateDXG]") TEXT("Primary surface create failed."), TEXT("MirDXG"), MB_ICONERROR | MB_OK);
- return E_FAIL;
- }
- UpdateBoundsWnd();
- if ( m_bDeviceModeFlag & _DXG_DEVICEMODE_D3D )
- {
- if ( FAILED( hr = m_pDD->QueryInterface(IID_IDirect3D7, (VOID**)&m_pD3D)) )
- return E_FAIL;
- if ( FAILED(hr = m_pD3D->CreateDevice(*g_stDXGEnumDeviceInfo[bSelecedDevice].pDeviceGUID, m_pddsBackBuffer, &m_pd3dDevice)) )
- return E_FAIL;
- D3DVIEWPORT7 d3dVP = { 0, 0, m_stDisplayInfo.wWidth, m_stDisplayInfo.wHeight, 0.0f, 1.0f };
- if ( FAILED( hr = m_pd3dDevice->SetViewport(&d3dVP)) ) return hr;
- if ( m_bDeviceModeFlag & _DXG_DEVICEMODE_ZBUFFER )
- {
- if ( FAILED(hr = CreateZBuffer(g_stDXGEnumDeviceInfo[bSelecedDevice].pDeviceGUID)) )
- {
- MessageBox(m_hWnd, TEXT("[CWHDXGraphicWindow::CreateDXG]") TEXT("ZBuffer create failed."), TEXT("MirDXG"), MB_ICONERROR | MB_OK);
- return E_FAIL;
- }
- }
- }
- m_stBitsMaskInfo = GetRGBMaskInfoIN16Bits(m_pddsBackBuffer);
- Init3DDeviceObjects();
- return S_OK;
- }
- return hr;
- }
- /******************************************************************************************************************
- 窃荐疙 : CDXGraphic::ResetDXG()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : WORD wWidth
- WORD wHeight
- WORD wBPP
- BYTE bScreenModeFlag
- BYTE bDeviceModeFlag
- 免仿 : HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HRESULT CWHDXGraphicWindow::ResetDXG(WORD wWidth, WORD wHeight, WORD wBPP, BYTE bScreenModeFlag, BYTE bDeviceModeFlag)
- {
- HRESULT hr;
- DWORD dwStyle;
- if ( m_bDeviceModeFlag == bDeviceModeFlag && m_bScreenModeFlag == bScreenModeFlag &&
- m_stDisplayInfo.wWidth == wWidth && m_stDisplayInfo.wHeight == wHeight && m_stDisplayInfo.wBPP == wBPP )
- return E_FAIL;
- if ( FAILED(DestroyDXGObjects()) )
- {
- MessageBox(m_hWnd, TEXT("[CWHDXGraphicWindow::ResetDXG]") TEXT("DirectGraphic reset failed."), "MirDXG", MB_ICONERROR | MB_OK);
- return E_FAIL;
- }
- m_stDisplayInfo.wWidth = wWidth;
- m_stDisplayInfo.wHeight = wHeight;
- m_stDisplayInfo.wBPP = wBPP;
- m_bScreenModeFlag = bScreenModeFlag;
- m_bDeviceModeFlag = bDeviceModeFlag;
- if ( m_bScreenModeFlag & _DXG_SCREENMODE_WINDOW )
- {
- dwStyle = GetWindowStyle(m_hWnd);
- dwStyle &= ~WS_POPUP;
- dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_SYSMENU;
- SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
- }
- else
- {
- dwStyle = GetWindowStyle(m_hWnd);
- dwStyle &= ~dwStyle;
- dwStyle |= WS_POPUP;
- SetWindowLong(m_hWnd, GWL_STYLE, dwStyle);
- }
- if ( hr = FAILED(CreateDXG()) )
- {
- MessageBox(m_hWnd, TEXT("[CWHDXGraphicWindow::ResetDXG]") TEXT("DirectGraphic create failed."), "MirDXG", MB_ICONERROR | MB_OK);
- return E_FAIL;
- }
- CreateDefFont();
- return S_OK;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::CreatePrimarySurface()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HRESULT CWHDXGraphicWindow::CreatePrimarySurface()
- {
- DDSURFACEDESC2 ddsd;
- HRESULT hr;
- ZeroMemory(&ddsd, sizeof(ddsd));
- ddsd.dwSize = sizeof(ddsd);
-
- if ( m_bScreenModeFlag & _DXG_SCREENMODE_WINDOW )
- {
- RECT rcWork;
- RECT rcTemp;
- GetWindowRect(m_hWnd, &rcTemp);
-
- // 努扼捞攫飘康开狼 农扁甫 棱绰何盒篮 扩档快狼 积己苞 包访捞 乐促.
- // 拳搁秦惑档 溜, 努扼捞攫飘 荤阿屈 康开狼 农扁甫 掘绢柯促.
- SetRect(&rcTemp, 0, 0, m_stDisplayInfo.wWidth, m_stDisplayInfo.wHeight);
- // 努扼捞攫飘 荤阿屈 康开农扁俊辑 扩档快 傈眉康开狼 农扁肺 函券茄促.
- AdjustWindowRectEx(&rcTemp, GetWindowStyle(m_hWnd), GetMenu(m_hWnd) != NULL, GetWindowExStyle(m_hWnd));
- // 扩档快 傈眉康开农扁肺 扩档快甫 技泼茄促. 窜 矫累谅钎绰 公矫等促.
- SetWindowPos(m_hWnd, NULL, 0, 0, rcTemp.right-rcTemp.left, rcTemp.bottom-rcTemp.top,
- SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
- // HWND_NOTOPMOST甫 技泼窍扁 困秦辑捞促.
- SetWindowPos(m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
- // 官帕拳搁康开狼 农扁甫 掘绢柯促..
- SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWork, 0);
- GetWindowRect(m_hWnd, &rcTemp);
- if ( rcTemp.left < rcWork.left ) rcTemp.left = rcWork.left;
- if ( rcTemp.top < rcWork.top ) rcTemp.top = rcWork.top;
- // 扩档快狼 矫累谅钎甫 技泼茄促.
- SetWindowPos(m_hWnd, NULL, rcTemp.left, rcTemp.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
-
- ddsd.dwFlags = DDSD_CAPS;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- if ( FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pddsFrontBuffer, NULL)) ) return E_FAIL;
- ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
- if ( m_bDeviceModeFlag & _DXG_DEVICEMODE_D3D )
- ddsd.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
- ddsd.dwWidth = m_stDisplayInfo.wWidth;
- ddsd.dwHeight = m_stDisplayInfo.wHeight;
- if ( FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pddsBackBuffer, NULL)) ) return E_FAIL;
- }
- else
- {
- ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
- ddsd.dwBackBufferCount = 1;
- if ( m_bDeviceModeFlag & _DXG_DEVICEMODE_D3D )
- ddsd.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
- if ( FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pddsFrontBuffer, NULL)) ) return E_FAIL;
- DDSCAPS2 ddscaps;
- ZeroMemory(&ddscaps, sizeof(ddscaps));
- ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
- if ( FAILED(hr = m_pddsFrontBuffer->GetAttachedSurface(&ddscaps, &m_pddsBackBuffer)) )
- return E_FAIL;
- }
- // 俊叼飘扩档快 免仿阑 困秦辑 努府欺甫 技泼茄促.////////////////////////////////////////////////////////////////
- if ( FAILED(hr = m_pDD->CreateClipper(0, &m_lpcClipper, NULL)) ) return E_FAIL;
- if ( FAILED(hr = m_lpcClipper->SetHWnd(0, m_hWnd)) )
- {
- m_lpcClipper->Release();
- return E_FAIL;
- }
- if ( FAILED(hr = m_pddsFrontBuffer->SetClipper(m_lpcClipper)) )
- {
- m_lpcClipper->Release();
- return E_FAIL;
- }
- m_pDD->FlipToGDISurface();
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- return S_OK;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::UpdateBoundsWnd()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : VOID
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- VOID CWHDXGraphicWindow::UpdateBoundsWnd()
- {
- if ( m_bScreenModeFlag & _DXG_SCREENMODE_WINDOW )
- {
- GetClientRect(m_hWnd, &m_rcWindow);
- ClientToScreen(m_hWnd, (POINT*)&m_rcWindow);
- ClientToScreen(m_hWnd, (POINT*)&m_rcWindow+1);
- }
- else
- {
- SetRect(&m_rcWindow, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
- }
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::CreateZBuffer()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : GUID* pDeviceGUID
- 免仿 : HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HRESULT CWHDXGraphicWindow::CreateZBuffer(GUID* pDeviceGUID)
- {
- HRESULT hr;
- D3DDEVICEDESC7 ddDesc;
- m_pd3dDevice->GetCaps(&ddDesc);
- if (ddDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBUFFERLESSHSR)
- return S_OK;
- DDSURFACEDESC2 ddsd;
- ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
- ddsd.dwSize = sizeof(ddsd);
- m_pddsBackBuffer->GetSurfaceDesc(&ddsd);
- ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS | DDSD_PIXELFORMAT;
- ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER;
- ddsd.ddpfPixelFormat.dwSize = 0;
- if ( FAILED(hr = m_pD3D->EnumZBufferFormats(*pDeviceGUID, DXGEnumZBufferFormatsCallback, (VOID*)&ddsd.ddpfPixelFormat)) )
- return E_FAIL;
- if ( 0 == ddsd.ddpfPixelFormat.dwSize )
- {
- ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
- if ( FAILED(hr = m_pD3D->EnumZBufferFormats(*pDeviceGUID, DXGEnumZBufferFormatsCallback, (VOID*)&ddsd.ddpfPixelFormat)) )
- return E_FAIL;
- if ( 0 == ddsd.ddpfPixelFormat.dwSize )
- return E_FAIL;
- }
- if ( FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pddsZBuffer, NULL)) ) return E_FAIL;
- if ( FAILED(hr = m_pddsBackBuffer->AddAttachedSurface(m_pddsZBuffer)) ) return E_FAIL;
- if ( FAILED(hr = m_pd3dDevice->SetRenderTarget(m_pddsBackBuffer, 0L)) )
- {
- return E_FAIL;
- }
- return S_OK;
- }
- HRESULT CWHDXGraphicWindow::Init3DDeviceObjects()
- {
- // Set the transform matrices
- D3DMATRIX matWorld, matView, matProj;
- // 泅犁 800*600拳搁俊 嘎霸 3D 谅钎拌甫 汲沥茄促.
- D3DVECTOR vEyePt = D3DVECTOR(0, 0, -300.0f);
- D3DVECTOR vLookatPt = D3DVECTOR(0, 0, 0);
- D3DVECTOR vUpVec = D3DVECTOR(0, 1, 0);
- D3DUtil_SetIdentityMatrix(matWorld);
- D3DUtil_SetViewMatrix(matView, vEyePt, vLookatPt, vUpVec);
- D3DUtil_SetProjectionMatrix(matProj, g_PI/2, float(600.0f/800.0f), -1.0f, 1.0f);
- // MATRIAL狼 檬扁拳甫 汲沥茄促.
- D3DMATERIAL7 mtrl;
- ZeroMemory(&mtrl, sizeof(mtrl));
- mtrl.diffuse.r = mtrl.diffuse.g = mtrl.diffuse.b = 0.1f;
- mtrl.ambient.r = mtrl.ambient.g = mtrl.ambient.b = 1.0f;
- m_pd3dDevice->SetMaterial(&mtrl);
- if ( !m_pd3dDevice )
- return E_FAIL;
- m_pd3dDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
- m_pd3dDevice->SetTransform(D3DTRANSFORMSTATE_VIEW, &matView);
- m_pd3dDevice->SetTransform(D3DTRANSFORMSTATE_PROJECTION, &matProj);
- // RenderState狼 檬扁蔼 汲沥.
- m_pd3dDevice->SetRenderState(D3DRENDERSTATE_AMBIENT, 0xFFFFFFFF);
- m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE);
- m_pd3dDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE);
- m_pd3dDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, D3DZB_FALSE);
- m_pd3dDevice->SetRenderState(D3DRENDERSTATE_FILLMODE, D3DFILL_SOLID);
- // m_pd3dDevice->SetRenderState(D3DRENDERSTATE_FILLMODE, D3DFILL_WIREFRAME);
- // m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SHADEMODE, D3DSHADE_GOURAUD);
-
- // TextureStageState狼 檬扁蔼 汲沥.
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFN_POINT);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_POINT);
- m_pd3dDevice->SetTextureStageState(0, D3DTSS_MIPFILTER, D3DTFP_NONE);
- return S_OK;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::CreateGameFont()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : LPCSTR szFontName
- INT nXsize
- INT nYsize
- BYTE bFontType
- 免仿 : VOID
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HFONT CWHDXGraphicWindow::CreateGameFont(LPCSTR szFontName, INT nHeight, INT nWidth, INT nWeight, BOOL bItalic, BOOL bULine, BOOL bStrikeOut, DWORD dwCharSet)
- {
- INT nYsize;
- // 迄飘农扁 嘎眠扁.
- if ( m_pddsBackBuffer )
- {
- HDC hDC;
- m_pddsBackBuffer->GetDC(&hDC);
- nYsize = -MulDiv(nHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72);
- m_pddsBackBuffer->ReleaseDC(hDC);
- }
- return CreateFont(nYsize, nWidth, 0, 0, nWeight, bItalic, bULine, bStrikeOut, dwCharSet,
- OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
- DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN, szFontName);
- }
- VOID CWHDXGraphicWindow::CreateDefFont()
- {
- // 捞固 扁夯迄飘啊 积己登绢 乐栏搁 货肺 父甸荐 乐档废 Clear.
- if ( m_hDefGameFont != NULL )
- {
- DeleteObject(m_hDefGameFont);
- m_hDefGameFont = NULL;
- }
- m_hDefGameFont = CreateGameFont("奔覆", 9);
- }
- VOID CWHDXGraphicWindow::StringPlus(CHAR* szResult, CHAR* szSrc, ...)
- {
- INT nCnt = 0;
- va_list vaMarker;
- CHAR* pszString;
- // ZeroMemory(szResult, strlen(szResult));
- va_start(vaMarker, szSrc);
- pszString = szSrc;
-
- while ( TRUE )
- {
- strcpy(&szResult[strlen(szResult)], pszString);
- if ( !strcmp(pszString, "") ) break;
- pszString = (CHAR*)va_arg(vaMarker, CHAR*);
- }
- va_end(vaMarker);
- }
- CHAR* CWHDXGraphicWindow::IntToStr(INT nNum)
- {
- static CHAR szResult[MAX_PATH];
- ZeroMemory(szResult, MAX_PATH);
- _itoa(nNum, szResult, 10);
- return szResult;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::PutsHan()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : LPDIRECTDRAWSURFACE7 pSurface
- INT nX
- INT nY
- COLORREF foreColor
- COLORREF backColor
- CHAR* szFormat
- ...
- 免仿 : VOID
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- VOID CWHDXGraphicWindow::PutsHan(LPDIRECTDRAWSURFACE7 pSurface, INT nX, INT nY, COLORREF foreColor, COLORREF backColor, CHAR* szText, HFONT hFont)
- {
- HDC hDC;
- HFONT hOldFont;
- if (NULL == pSurface)
- pSurface = m_pddsBackBuffer;
-
- if ( NULL == pSurface )
- return;
- if ( NULL == hFont )
- hFont = m_hDefGameFont;
- HRESULT hr = pSurface->GetDC(&hDC);
- if (backColor == RGB( 0, 0, 0 )) SetBkMode(hDC, TRANSPARENT);
- else SetBkColor(hDC, backColor);
- hOldFont = (HFONT)SelectObject(hDC, hFont);
- SetTextColor(hDC, foreColor);
- TextOut(hDC, nX, nY, szText, strlen(szText));
- SelectObject(hDC, hOldFont);
- if ( hFont != m_hDefGameFont )
- DeleteObject(hFont);
-
- pSurface->ReleaseDC(hDC);
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::PutsHan()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : LPDIRECTDRAWSURFACE7 pSurface
- INT nX
- INT nY
- COLORREF foreColor
- COLORREF backColor
- CHAR* szFormat
- ...
- 免仿 : VOID
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- VOID CWHDXGraphicWindow::PutsHan(LPDIRECTDRAWSURFACE7 pSurface, RECT rc, COLORREF foreColor, COLORREF backColor, CHAR* szText, HFONT hFont)
- {
- HDC hDC;
- HFONT hOldFont;
- if (NULL == pSurface)
- pSurface = m_pddsBackBuffer;
-
- if ( NULL == pSurface )
- return;
- if ( NULL == hFont )
- hFont = m_hDefGameFont;
- HRESULT hr = pSurface->GetDC(&hDC);
- if (backColor == RGB( 0, 0, 0 )) SetBkMode(hDC, TRANSPARENT);
- else SetBkColor(hDC, backColor);
- hOldFont = (HFONT)SelectObject(hDC, hFont);
- SetTextColor(hDC, foreColor);
- DrawText(hDC, szText, -1, &rc, DT_CENTER|DT_SINGLELINE);
- SelectObject(hDC, hOldFont);
- if ( hFont != m_hDefGameFont )
- DeleteObject(hFont);
-
- pSurface->ReleaseDC(hDC);
- }
- SIZE CWHDXGraphicWindow::GetStrLength(LPDIRECTDRAWSURFACE7 pSurface, HFONT hFont, CHAR* szFormat, ...)
- {
- HDC hDC;
- va_list arg;
- CHAR szBuf[1024];
- SIZE sSize;
-
- sSize.cx = 0;
- sSize.cy = 0;
- HFONT hOldFont;
- if ( NULL == pSurface )
- pSurface = m_pddsBackBuffer;
-
- if ( NULL == pSurface ) return sSize;
- if ( NULL == hFont )
- hFont = m_hDefGameFont;
- HRESULT hr = pSurface->GetDC(&hDC);
- va_start(arg, szFormat);
- vsprintf(szBuf, szFormat, arg);
- va_end(arg);
- hOldFont = (HFONT)SelectObject(hDC, hFont);
- GetTextExtentPoint32(hDC,szBuf,strlen(szBuf),&sSize);
- SelectObject(hDC, hOldFont);
-
- pSurface->ReleaseDC(hDC);
- return sSize;
- }
- /*BOOL CWHDXGraphicWindow::StringDivideLen(INT nDivideLen, INT& nDividedLine, CHAR* szSrc,CDLList<CHAR*>* m_pxpStr)
- {
- CHAR szTmpCheck[MAX_PATH];
- CHAR szResult[MAX_PATH];
-
- nDividedLine = 1;
- INT nStartLen = 0;
- INT nEndLen = 0;
- INT nResultLen = 0;
- INT nWordCheck = 0;
- if ( szSrc[0] != NULL )
- {
- ZeroMemory(szResult,MAX_PATH);
- for ( INT nCnt = 0; nCnt < (INT)strlen(szSrc); nCnt++)
- {
- ZeroMemory(szTmpCheck, MAX_PATH);
- nEndLen = nCnt+1;
- // 泅犁何盒鳖瘤狼 巩磊凯阑 佬绰促.
- memcpy(&szTmpCheck, &szSrc[nStartLen], nEndLen-nStartLen);
- INT nsLen;
- nsLen = strlen(szTmpCheck);
- // 泅犁鳖瘤 佬绢柯 何盒捞 倾侩承捞甫 逞绢脊阑锭.
- if (nsLen > nDivideLen )
- {
- // 泅犁 2官捞飘 巩磊扼搁.
- if ( szSrc[nEndLen-1] < 0 )
- {
- // 泅犁 菊俊巩磊啊 2官捞飘 巩磊啊 酒聪扼搁
- if ( !(nWordCheck%2) )
- {
- nStartLen += strlen(szTmpCheck)-1;
- nCnt--;
- CHAR* pszNewLine;
- pszNewLine = new CHAR[nResultLen+1];
- memcpy(pszNewLine,szResult,nResultLen);
- pszNewLine[nResultLen]=NULL;
- m_pxpStr->AddNode(pszNewLine);
- nResultLen = 0;
- nDividedLine++;
- }
- else
- {
- nStartLen += strlen(szTmpCheck)-2;
- nCnt -= 2;
- CHAR* pszNewLine;
- pszNewLine = new CHAR[nResultLen];
- memcpy(pszNewLine,szResult,nResultLen-1);
- pszNewLine[nResultLen-1]=NULL;
- m_pxpStr->AddNode(pszNewLine);
- nResultLen = 0;
- nDividedLine++;
- nWordCheck--;
- }
- }
- // 1官捞飘 巩磊.
- // 泅犁焊促 茄官捞飘菊何盒鳖瘤父 绊妨秦林搁 等促.
- else
- {
- nStartLen += strlen(szTmpCheck)-1;
- nCnt--;
- CHAR* pszNewLine;
- pszNewLine = new CHAR[nResultLen+1];
- memcpy(pszNewLine,szResult,nResultLen);
- pszNewLine[nResultLen]=NULL;
- m_pxpStr->AddNode(pszNewLine);
- nResultLen=0;
- nDividedLine++;
- }
- }
- else if(szSrc[nEndLen-1]=='n') // 碍力俺青 n栏肺窍搁 Error ????
- {
- nStartLen += strlen(szTmpCheck)-1;
- CHAR* pszNewLine;
- pszNewLine = new CHAR[nResultLen+1];
- memcpy(pszNewLine,szResult,nResultLen);
- pszNewLine[nResultLen]=NULL;
- m_pxpStr->AddNode(pszNewLine);
- nResultLen=0;
- nDividedLine++;
- }
- else
- {
- if ( szSrc[nEndLen-1] < 0 )
- nWordCheck++;
- szResult[nResultLen] = szSrc[nEndLen-1];
- nResultLen++;
- }
- }
- if(nResultLen!=0)
- {
- CHAR* pszNewLine;
- pszNewLine = new CHAR[nResultLen+1];
- memcpy(pszNewLine,szResult,nResultLen);
- pszNewLine[nResultLen]=NULL;
- m_pxpStr->AddNode(pszNewLine);
- nDividedLine++;
- nResultLen=0;
- }
- return TRUE;
- }
- return FALSE;
- }
- */
- BOOL CWHDXGraphicWindow::StringDivide(INT nDivideWidth, INT& nDividedLine, CHAR* szSrc, CHAR* szResult)
- {
- CHAR szTmpCheck[MAX_PATH];
-
- nDividedLine = 1;
- INT nStartLen = 0;
- INT nEndLen = 0;
- INT nResultLen = 0;
- INT nWordCheck = 0;
- if ( szSrc[0] != NULL )
- {
- ZeroMemory(szResult, MAX_PATH);
- for ( INT nCnt = 0; nCnt < (INT)strlen(szSrc); nCnt++)
- {
- ZeroMemory(szTmpCheck, MAX_PATH);
- nEndLen = nCnt+1;
- // 父距俊 臂磊农扁啊 弥措 臂磊农扁甫 逞绢啊搁 弥措摹肺 嘎苗霖促.
- if ( nEndLen >= MAX_PATH )
- {
- szResult[MAX_PATH-1] = NULL;
- break;
- }
- // 泅犁何盒鳖瘤狼 巩磊凯阑 佬绰促.
- memcpy(&szTmpCheck, &szSrc[nStartLen], nEndLen-nStartLen);
- SIZE sizeLen;
- sizeLen = GetStrLength(NULL, NULL, szTmpCheck);
- // 泅犁鳖瘤 佬绢柯 何盒捞 倾侩承捞甫 逞绢脊阑锭.
- if ( sizeLen.cx > nDivideWidth )
- {
- // 泅犁 2官捞飘 巩磊扼搁.
- if ( szSrc[nEndLen-1] < 0 )
- {
- // 泅犁 菊俊巩磊啊 2官捞飘 巩磊啊 酒聪扼搁
- if ( !(nWordCheck%2) )
- {
- nStartLen += strlen(szTmpCheck)-1;
- nCnt--;
- szResult[nResultLen] = '`';
- nResultLen++;
- nDividedLine++;
- }
- else
- {
- nStartLen += strlen(szTmpCheck)-2;
- nCnt -= 2;
- szResult[nResultLen-1] = '`';
- nDividedLine++;
- nWordCheck--;
- }
- }
- // 1官捞飘 巩磊.
- // 泅犁焊促 茄官捞飘菊何盒鳖瘤父 绊妨秦林搁 等促.
- else
- {
- nStartLen += strlen(szTmpCheck)-1;
- nCnt--;
- szResult[nResultLen] = '`';
- nResultLen++;
- nDividedLine++;
- }
- }
- else
- {
- if ( szSrc[nEndLen-1] < 0 )
- nWordCheck++;
- szResult[nResultLen] = szSrc[nEndLen-1];
- nResultLen++;
- }
- }
- return TRUE;
- }
- return FALSE;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::GetRGBMaskInfoIN16Bits()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : LPDIRECTDRAWSURFACE7 pSurface
- 免仿 : DXG_MASKINFO
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- DXG_MASKINFO CWHDXGraphicWindow::GetRGBMaskInfoIN16Bits(LPDIRECTDRAWSURFACE7 pSurface)
- {
- DDPIXELFORMAT ddpf;
- DXG_MASKINFO stRGBMaskInfo;
- ZeroMemory(&stRGBMaskInfo, sizeof(DXG_MASKINFO));
- if ( pSurface == NULL ) pSurface = m_pddsBackBuffer;
- if ( pSurface )
- {
- memset(&ddpf, 0, sizeof(ddpf));
- ddpf.dwSize = sizeof(ddpf);
- ddpf.dwFlags = DDPF_RGB;
- pSurface->GetPixelFormat(&ddpf);
- stRGBMaskInfo.dwRMask = ddpf.dwRBitMask;
- stRGBMaskInfo.dwGMask = ddpf.dwGBitMask;
- stRGBMaskInfo.dwBMask = ddpf.dwBBitMask;
- DWORD dwCnt;
- DWORD dwMask;
- for ( dwCnt = 0, dwMask = ddpf.dwRBitMask; !( dwMask & 1 ); dwCnt++, dwMask >>= 1 );
- stRGBMaskInfo.bRShift = (BYTE) dwCnt;
- for ( dwCnt = 0; ( ( dwMask>>dwCnt ) & 1 ); dwCnt++ );
- stRGBMaskInfo.bRCnt = (BYTE) dwCnt;
- for ( dwCnt = 0, dwMask = ddpf.dwGBitMask; !( dwMask & 1 ); dwCnt++, dwMask >>= 1 );
- stRGBMaskInfo.bGShift = (BYTE) dwCnt;
- for ( dwCnt = 0; ( ( dwMask>>dwCnt ) & 1 ); dwCnt++ );
- stRGBMaskInfo.bGCnt = (BYTE) dwCnt;
- for ( dwCnt = 0, dwMask = ddpf.dwBBitMask; !( dwMask & 1 ); dwCnt++, dwMask >>= 1 );
- stRGBMaskInfo.bBShift = (BYTE) dwCnt;
- for ( dwCnt = 0; ( ( dwMask>>dwCnt ) & 1 ); dwCnt++ );
- stRGBMaskInfo.bBCnt = (BYTE) dwCnt;
- }
- return stRGBMaskInfo;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // 弊府绰 窃荐甸 葛澜.
- WORD CWHDXGraphicWindow::ConvertColor24To16(COLORREF dwColor)
- {
- WORD wRet;
- INT nRed = RGB_GETRED(dwColor);
- INT nGreen = RGB_GETGREEN(dwColor);
- INT nBlue = RGB_GETBLUE(dwColor);
-
- nRed = (nRed*(1<<m_stBitsMaskInfo.bRCnt))/(1<<8);
- nGreen = (nGreen*(1<<m_stBitsMaskInfo.bGCnt))/(1<<8);
- nBlue = (nBlue*(1<<m_stBitsMaskInfo.bBCnt))/(1<<8);
- wRet = (nRed << m_stBitsMaskInfo.bRShift) | (nGreen << m_stBitsMaskInfo.bGShift) | (nBlue << m_stBitsMaskInfo.bBShift);
- return wRet;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::DrawWithGDI()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : RECT rc
- LPDIRECTDRAWSURFACE7 pSurface
- DWORD dwColor
- DWORD dwPenStyleFlg
- BYTE bKind
- 免仿 : HRESULT
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- HRESULT CWHDXGraphicWindow::DrawWithGDI(RECT rc, LPDIRECTDRAWSURFACE7 pSurface, DWORD dwColor, BYTE bKind)
- {
- POINT pt;
- HDC hDC;
- HPEN hPen, hOldPen;
- HBRUSH hBrush, hOldBrush;
- HRESULT hr;
- if ( pSurface == NULL )
- {
- pSurface = m_pddsBackBuffer;
- }
- if ( pSurface == NULL )
- return E_FAIL;
- if ( FAILED(hr = pSurface->GetDC(&hDC)) )
- {
- return E_FAIL;
- }
- switch ( bKind )
- {
- case 0:
- {
- hPen = CreatePen(PS_SOLID, NULL, dwColor);
-
- hOldPen = (HPEN)SelectObject(hDC, hPen);
- MoveToEx(hDC, rc.left, rc.top, &pt);
- LineTo(hDC, rc.right, rc.bottom);
- SelectObject(hDC, hOldPen);
- DeleteObject(hPen);
- }
- break;
- case 1:
- {
- hBrush = CreateSolidBrush(dwColor);
- hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
- FrameRect(hDC, &rc, hBrush);
- SelectObject(hDC, hOldBrush);
- DeleteObject(hBrush);
- }
- break;
- case 2:
- {
- hBrush = CreateSolidBrush(dwColor);
- hOldBrush = (HBRUSH)SelectObject(hDC, hBrush);
- FillRect(hDC, &rc, hBrush);
- SelectObject(hDC, hOldBrush);
- DeleteObject(hBrush);
- }
- break;
- default:
- break;
- }
- pSurface->ReleaseDC(hDC);
- return S_OK;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::DrawSprite()
- 累己磊 :
- 累己老 :
- 格利 : 老馆利牢 弊府扁. 茄侨伎究 弊赴促. 胶农赴康开 努府俏, 家胶康开 努府俏
- 涝仿 : INT nX
- INT nY
- INT nXSize
- INT nYSize
- WORD* pwSrc
- 免仿 : VOID
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BOOL CWHDXGraphicWindow::DrawWithImage(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc)
- {
- RECT rc;
- DDSURFACEDESC2 ddsd;
- INT nWidth = nXSize;
- INT nHeight = nYSize;
- INT nXOffset = 0;
- INT nYOffset = 0;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = m_stDisplayInfo.wWidth -1;
- INT nEndY = m_stDisplayInfo.wHeight-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;
- for ( INT y=rc.top ; y < rc.bottom ; y++ )
- {
- for ( INT x=rc.left ; x < rc.right ; x++ )
- {
- if ( pwSrc[y * nXSize + x] != 0 )
- {
- pwdDst[((y+nY) * (ddsd.lPitch >> 1)) + (nX+x)] = pwSrc[y * nXSize + x];
- }
- }
- }
- m_pddsBackBuffer->Unlock(NULL);
- }
- return TRUE;
- }
- return FALSE;
- }
- BOOL CWHDXGraphicWindow::DrawWithImagePerLineClipRgn(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, WORD wClipWidth, WORD wClipHeight)
- {
- 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;
- for ( INT y=rc.top ; y < rc.bottom ; y++ )
- {
- memcpy(&pwdDst[((y+nY) * (ddsd.lPitch >> 1)) + (nX + rc.left)], &pwSrc[y * nXSize + rc.left], (rc.right-rc.left)*2);
- }
- m_pddsBackBuffer->Unlock(NULL);
- }
- return TRUE;
- }
- return FALSE;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHDXGraphicWindow::DrawWithSurface()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : LPDIRECTDRAWSURFACE7 pddsSrc
- RECT* prcSrc
- RECT* prcDst
- 免仿 : BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BOOL CWHDXGraphicWindow::DrawWithSurface(INT nX, INT nY, INT nXSize, INT nYSize, LPDIRECTDRAWSURFACE7 pddsSrc)
- {
- RECT rc;
- RECT rcDst;
- INT nXOffset = 0;
- INT nYOffset = 0;
- INT nWidth = nXSize;
- INT nHeight = nYSize;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = m_stDisplayInfo.wWidth -1;
- INT nEndY = m_stDisplayInfo.wHeight-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;
- rcDst.left = rc.left+nX;
- rcDst.top = rc.top+nY;
- rcDst.right = rc.right+nX;
- rcDst.bottom = rc.bottom+nY;
- m_pddsBackBuffer->Blt(&rcDst, pddsSrc, &rc, DDBLT_WAIT|DDBLT_KEYSRC, NULL);
- }
- return TRUE;
- }
- return FALSE;
- }
- BOOL CWHDXGraphicWindow::DrawWithImageForCompMemToMem(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, INT nDstXSize, INT nDstYSize, WORD* pwDst, WORD wChooseColor1, WORD wChooseColor2)
- {
- RECT rc;
- INT nWidth = nXSize;
- INT nHeight = nYSize;
- INT nXOffset = 0;
- INT nYOffset = 0;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = nDstXSize - 1;
- INT nEndY = nDstYSize - 1;
- if ( pwDst != 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;
- 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);
- memcpy(&pwDst[((nYCnt+nY) * nDstXSize) + (rc.left+nX)], &pwSrc[x], sizeof(WORD)*(nCurrWidth-rc.left));
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- memcpy(&pwDst[((nYCnt+nY) * nDstXSize) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*(rc.right-nLastWidth));
- x += nCntCopyWord;
- }
- else
- {
- memcpy(&pwDst[((nYCnt+nY) * nDstXSize) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*nCntCopyWord);
- 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);
- pwDst[((nYCnt+nY) * nDstXSize) + (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);
- pwDst[((nYCnt+nY) * nDstXSize) + (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);
- pwDst[((nYCnt+nY) * nDstXSize) + (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::DrawWithImageForComp(INT nX, INT nY, RECT rcSrc, WORD* pwSrc, WORD wChooseColor1, WORD wChooseColor2)
- {
- RECT rc;
- DDSURFACEDESC2 ddsd;
- INT nWidth = rcSrc.right-rcSrc.left;
- INT nHeight = rcSrc.bottom-rcSrc.top;
- INT nXOffset = rcSrc.left;
- INT nYOffset = rcSrc.top;
- INT nStartX = 0;
- INT nStartY = 0;
- INT nEndX = m_stDisplayInfo.wWidth -1;
- INT nEndY = m_stDisplayInfo.wHeight-1;
- if ( m_pddsBackBuffer != NULL )
- {
- if (nX < nStartX )
- {
- nXOffset += nStartX - nX;
- nWidth = rcSrc.right - nXOffset;
- }
- if ( (nX+rcSrc.right-rcSrc.left-1) > nEndX )
- nWidth = nEndX - nX - nXOffset + 1;
- if ( nY < nStartY )
- {
- nYOffset += nStartY - nY;
- nHeight = rcSrc.bottom - nYOffset;
- }
- if ( (nY+rcSrc.bottom-rcSrc.top-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);
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX)], &pwSrc[x], sizeof(WORD)*(nCurrWidth-rc.left));
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*(rc.right-nLastWidth));
- x += nCntCopyWord;
- }
- else
- {
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*nCntCopyWord);
- 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);
- 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);
- 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);
- 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::DrawWithImageForComp(INT nX, INT nY, INT nXSize, INT nYSize, WORD* pwSrc, 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 = m_stDisplayInfo.wWidth -1;
- INT nEndY = m_stDisplayInfo.wHeight-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;
- 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);
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX)], &pwSrc[x], sizeof(WORD)*(nCurrWidth-rc.left));
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*(rc.right-nLastWidth));
- x += nCntCopyWord;
- }
- else
- {
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*nCntCopyWord);
- 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);
- 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);
- 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);
- 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::DrawWithImageForCompClipRgnBase(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;
- 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);
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX)], &pwSrc[x], sizeof(WORD)*(nCurrWidth-rc.left));
- x += (nCurrWidth-rc.left);
- }
- // rc.right痢阑 扁霖栏肺 墨乔且 康开捞 吧赴 版快.
- else if ( nLastWidth <= rc.right && rc.right < nCurrWidth )
- {
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*(rc.right-nLastWidth));
- x += nCntCopyWord;
- }
- else
- {
- memcpy(&pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX)], &pwSrc[x], sizeof(WORD)*nCntCopyWord);
- 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);
- 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);
- 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);
- 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::DrawWithABlendCompDataWithBackBuffer(INT nX, INT nY,
- INT nXSize, INT nYSize, WORD* pwSrc,
- WORD wClipWidth, WORD wClipHeight,
- WORD wChooseColor1, WORD wChooseColor2, BYTE bOpa)
- {
- 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;
- WORD wDyingKind, wChooseColor;
- 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 bRedDst, bGreenDst, bBlueDst;
- BYTE bRedSrc, bGreenSrc, bBlueSrc;
- BYTE bRedWantedColor, bGreenWantedColor, bBlueWantedColor;
- WORD wPixel;
- 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);
- wPixel = pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+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)((bOpa*(bBlueDst -bBlueSrc )+100*bBlueSrc ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenSrc)+100*bGreenSrc ) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedSrc )+100*bRedSrc ) / 100);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX+nCheck)] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<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 = 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);
- 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)((bOpa*(bBlueDst -bBlueSrc )+100*bBlueSrc ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenSrc)+100*bGreenSrc ) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedSrc )+100*bRedSrc ) / 100);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<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);
- 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)((bOpa*(bBlueDst -bBlueSrc )+100*bBlueSrc ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenSrc)+100*bGreenSrc ) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedSrc )+100*bRedSrc ) / 100);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<m_stBitsMaskInfo.bBShift));
- }
- 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);
- wPixel = pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+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)((bOpa*(bBlueDst -bBlueWantedColor )+100*bBlueWantedColor ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenWantedColor)+100*bGreenWantedColor) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedWantedColor )+100*bRedWantedColor ) / 100);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (rc.left+nX+nCheck)] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<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);
- 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)((bOpa*(bBlueDst -bBlueWantedColor )+100*bBlueWantedColor ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenWantedColor)+100*bGreenWantedColor) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedWantedColor )+100*bRedWantedColor ) / 100);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<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);
- 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)((bOpa*(bBlueDst -bBlueWantedColor )+100*bBlueWantedColor ) / 100);
- bGreenDst = (BYTE)((bOpa*(bGreenDst-bGreenWantedColor)+100*bGreenWantedColor) / 100);
- bRedDst = (BYTE)((bOpa*(bRedDst -bRedWantedColor )+100*bRedWantedColor ) / 100);
- pwdDst[((nYCnt+nY) * (ddsd.lPitch >> 1)) + (nLastWidth+nX+nCheck)] = ((bRedDst <<m_stBitsMaskInfo.bRShift) |
- (bGreenDst<<m_stBitsMaskInfo.bGShift) |
- (bBlueDst <<m_stBitsMaskInfo.bBShift));
- }
- x += nCntCopyWord;
- }
- }
- }
- }
- // 扼牢狼 场阑 促澜 扼牢狼 矫累栏肺 颗败霖促.
- nWidthEnd++;