WHSurface.cpp
上传用户:cydong117
上传日期:2009-11-10
资源大小:638k
文件大小:3k
- /******************************************************************************************************************
-
- 葛碘疙:
-
- 累己磊:
- 累己老:
-
- [老磊][荐沥磊] : 荐沥 郴侩
-
- *******************************************************************************************************************/
- #include "stdafx.h"
- #include "WHEngine.h"
- /******************************************************************************************************************
- 窃荐疙 : CWHSurface::ReleaseSurface()
- 累己磊 :
- 累己老 :
- 格利 :
- 免仿 : BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BOOL CWHSurface::ReleaseSurface()
- {
- if ( m_pDDS )
- {
- m_pDDS->Release();
- m_pDDS = NULL;
- return TRUE;
- }
- return FALSE;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHSurface::CreateOffScreenSurface()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : LPDIRECTDRAW7 pDD
- DWORD dwXSize
- DWORD dwYSize
- 免仿 : BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BOOL CWHSurface::CreateOffScreenSurface(LPDIRECTDRAW7 pDD, DWORD dwXSize, DWORD dwYSize)
- {
- HRESULT hr;
- DDSURFACEDESC2 ddsd;
- ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
- ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
- ddsd.dwWidth = dwXSize;
- ddsd.dwHeight = dwYSize;
- hr = pDD->CreateSurface(&ddsd, &m_pDDS, NULL);
- if ( hr != DD_OK ) return FALSE;
- return TRUE;
- }
- /******************************************************************************************************************
- 窃荐疙 : CWHSurface::CopyImageToSurface()
- 累己磊 :
- 累己老 :
- 格利 :
- 涝仿 : DWORD dwSrcWidth
- DWORD dwSrcHeight
- WORD* pwSrc
- 免仿 : BOOL
- [老磊][荐沥磊] : 荐沥郴侩
- *******************************************************************************************************************/
- BOOL CWHSurface::CopyImageToSurface(DWORD dwSrcWidth, DWORD dwSrcHeight, WORD* pwSrc)
- {
- DDSURFACEDESC2 ddsd;
- WORD* pwdDst = NULL;
- ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
- ddsd.dwSize = sizeof(DDSURFACEDESC2);
- if (m_pDDS->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL) == DD_OK)
- {
- pwdDst = (WORD*)ddsd.lpSurface;
- CopyMemory(pwdDst, pwSrc, dwSrcWidth * dwSrcHeight * sizeof(WORD));
- m_pDDS->Unlock(NULL);
- DDCOLORKEY ddck;
- ddck.dwColorSpaceLowValue = RGB( 0, 0, 0);
- ddck.dwColorSpaceHighValue = RGB(10, 10, 10);
- m_pDDS->SetColorKey(DDCKEY_SRCBLT, &ddck);
- return TRUE;
- }
- return FALSE;
- }