当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECTDRAWSURFACE::GetSurfaceDesc方法代码示例

本文整理汇总了C++中LPDIRECTDRAWSURFACE::GetSurfaceDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECTDRAWSURFACE::GetSurfaceDesc方法的具体用法?C++ LPDIRECTDRAWSURFACE::GetSurfaceDesc怎么用?C++ LPDIRECTDRAWSURFACE::GetSurfaceDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECTDRAWSURFACE的用法示例。


在下文中一共展示了LPDIRECTDRAWSURFACE::GetSurfaceDesc方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

// initialization
STDMETHODIMP 
CDirect2DRMDevice::InitFromSurface(LPDIRECTDRAWSURFACE pdds)
{
	HRESULT hr;
	if (pdds == NULL)
		return E_NULLPOINTER;

//	if (m_pddsBackBuffer)
//		return E_ALREADYINITIALIZED;

	// release the old surface
	MMRELEASE(m_pddsBackBuffer);

	pdds->AddRef();
	m_pddsBackBuffer = pdds;

	if (FAILED(hr = pdds->GetSurfaceDesc(&m_ddsd)) ||
		FAILED(hr = m_pixi.Init(m_ddsd.ddpfPixelFormat)))
		return hr;

	// notify the viewports that the device has been resized
	for(DWORD i = 0, cLimit = m_dsViewports.Items(); i < cLimit; i++) {
		if (FAILED(hr = m_dsViewports[i]->DeviceResized()))
			return hr;
	}
	return S_OK;
}
开发者ID:opensim4opencog,项目名称:PrologVirtualWorlds,代码行数:28,代码来源:d2drmdev.cpp

示例2: DDGetRGB16

/*
 * GetRGB16:
 *    Must run this function to fill the RGB16 struct with the information needed to plot a pixel
 *      To call this, you must have rgb16 defined as a global (unless you want to modify this) variable
 *      RGB16 rgb16;
 */
void DDGetRGB16(void)
{
    DDSURFACEDESC   ddsd;       // DirectDraw Surface Description
    BYTE            shiftcount; // Shift Counter
    
    // get a surface despriction
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_PIXELFORMAT;
    lpDDSPrimary->GetSurfaceDesc(&ddsd);
    
    // Fill in the masking values for extracting colors
    rgb16.Mask.rgbRed = ddsd.ddpfPixelFormat.dwRBitMask;
    rgb16.Mask.rgbGreen = ddsd.ddpfPixelFormat.dwGBitMask;
    rgb16.Mask.rgbBlue = ddsd.ddpfPixelFormat.dwBBitMask;
    
    // get red surface information
    shiftcount = 0;
    while (!(ddsd.ddpfPixelFormat.dwRBitMask & 1)) {
        ddsd.ddpfPixelFormat.dwRBitMask >>= 1;
        shiftcount++;
    }
    rgb16.depth.rgbRed = (BYTE)ddsd.ddpfPixelFormat.dwRBitMask;
    rgb16.Position.rgbRed = shiftcount;
    rgb16.Amount.rgbRed = (ddsd.ddpfPixelFormat.dwRBitMask == 0x1f) ? 3 : 2;
    
    // get green surface information
    shiftcount = 0;
    while (!(ddsd.ddpfPixelFormat.dwGBitMask & 1)) {
        ddsd.ddpfPixelFormat.dwGBitMask >>= 1;
        shiftcount++;
    }
    rgb16.depth.rgbGreen = (BYTE)ddsd.ddpfPixelFormat.dwGBitMask;
    rgb16.Position.rgbGreen = shiftcount;
    rgb16.Amount.rgbGreen = (ddsd.ddpfPixelFormat.dwGBitMask == 0x1f) ? 3 : 2;
    
    // get Blue surface information
    shiftcount = 0;
    while (!(ddsd.ddpfPixelFormat.dwBBitMask & 1)) {
        ddsd.ddpfPixelFormat.dwBBitMask >>= 1;
        shiftcount++;
    }
    rgb16.depth.rgbBlue = (BYTE)ddsd.ddpfPixelFormat.dwBBitMask;
    rgb16.Position.rgbBlue = shiftcount;
    rgb16.Amount.rgbBlue = (ddsd.ddpfPixelFormat.dwBBitMask == 0x1f) ? 3 : 2;
    
    // fill in variables so we dont' have to access the structure anymore
    mRed = rgb16.Mask.rgbRed;         // Red Mask
    mGreen = rgb16.Mask.rgbGreen;     // Green Mask
    mBlue = rgb16.Mask.rgbBlue;       // Blue Mask
    pRed = rgb16.Position.rgbRed;     // Red Position
    pGreen = rgb16.Position.rgbGreen; // Green Position
    pBlue = rgb16.Position.rgbBlue;   // Blue Position
}
开发者ID:mreiferson,项目名称:dod,代码行数:59,代码来源:dodddraw.cpp

示例3: DDCopyBitmap

/*
 * DDCopyBitmap:
 *     draw a bitmap into a DirectDrawSurface
 */
HRESULT DDCopyBitmap(LPDIRECTDRAWSURFACE pdds, HBITMAP hbm, int x, int y, int dx, int dy)
{
    HDC                 hdcImage;
    HDC                 hdc;
    BITMAP              bm;
    DDSURFACEDESC       ddsd;
    HRESULT             hr;
    
    if (hbm == NULL || pdds == NULL) {
        return E_FAIL;
    }
    
    // make sure this surface is restored.
    pdds->Restore();
    
    //  select bitmap into a memoryDC so we can use it.
    hdcImage = CreateCompatibleDC(NULL);
    if (!hdcImage) {
        OutputDebugString("createcompatible dc failed\n");
    }
    SelectObject(hdcImage, hbm);
    
    // get size of the bitmap
    GetObject(hbm, sizeof(bm), &bm);    // get size of bitmap
    dx = dx == 0 ? bm.bmWidth  : dx;    // use the passed size, unless zero
    dy = dy == 0 ? bm.bmHeight : dy;
    
    // get size of surface.
    ddsd.dwSize = sizeof(ddsd);
    ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
    pdds->GetSurfaceDesc(&ddsd);
    
    if ((hr = pdds->GetDC(&hdc)) == DD_OK) {
        StretchBlt(hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage, x, y, dx, dy, SRCCOPY);
        pdds->ReleaseDC(hdc);
    }
    
    DeleteDC(hdcImage);
    
    return hr;
}
开发者ID:mreiferson,项目名称:dod,代码行数:45,代码来源:dodddraw.cpp


注:本文中的LPDIRECTDRAWSURFACE::GetSurfaceDesc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。