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


C++ LPDIRECTDRAWSURFACE7::GetDC方法代码示例

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


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

示例1: Draw_Text_GDI

int Draw_Text_GDI(char *text, int x,int y,COLORREF color, LPDIRECTDRAWSURFACE7 lpdds)
{
// this function draws the sent text on the sent surface 
// using color index as the color in the palette

HDC xdc; // the working dc

// get the dc from surface
if (FAILED(lpdds->GetDC(&xdc)))
   return(0);

// set the colors for the text up
SetTextColor(xdc,color);

// set background mode to transparent so black isn't copied
SetBkMode(xdc, TRANSPARENT);

// draw the text a
TextOut(xdc,x,y,text,strlen(text));

// release the dc
lpdds->ReleaseDC(xdc);

// return success
return(1);
} // end Draw_Text_GDI
开发者ID:calyx,项目名称:windows-game-source-code,代码行数:26,代码来源:demo7_14.cpp

示例2: dx_CopieBitmap

//-----------------------------------------------------------------------------
// Name: dx_CopieBitmap(...)
// Desc: Copie le contenu d'un bitmap dans le buffer d'affichage
//-----------------------------------------------------------------------------
bool dx_CopieBitmap (HBITMAP pBitmap, uint16 pPosX, uint16 pTailleX,
                     uint16 pPosY, uint16 pTailleY)
{
    HDC           hdcImage;
    HDC           hdc;
    BITMAP        bm;

    if (pBitmap == NULL) return false;

    SurfaceBack->Restore();

    hdcImage = CreateCompatibleDC (NULL);
    SelectObject (hdcImage, pBitmap);
    GetObject (pBitmap, sizeof(bm), &bm);

    pTailleX = pTailleX == 0 ? bm.bmWidth  : pTailleX;
    pTailleY = pTailleY == 0 ? bm.bmHeight : pTailleY;

    SurfaceBack->GetDC(&hdc);

    BitBlt (hdc, pPosX, pPosY, pTailleX, pTailleY, hdcImage, 0, 0, SRCCOPY);

    SurfaceBack->ReleaseDC(hdc);

    DeleteDC (hdcImage);

    return true;
}
开发者ID:hlemorvan,项目名称:vision-stereo,代码行数:32,代码来源:DirectDraw.cpp

示例3: dx_NombreGDI

bool dx_NombreGDI (uint32 pNombre, uint16 pPosX, uint16 pPosY, COLORREF pCouleur)
{
    // this function draws the sent text on the sent surface
    // using color index as the color in the palette

    HDC xdc; // the working dc

    // get the dc from surface
    if (FAILED (SurfaceBack->GetDC (&xdc))) return false;

    char pTexte[128];

    _itoa (pNombre, pTexte, 10);

    WCHAR Texte[128] = {0};
    MultiByteToWideChar (GetACP(), 0, pTexte, -1, Texte, 128);


    SetTextColor (xdc, pCouleur);       // set the colors for the text
    SetBkMode    (xdc, TRANSPARENT); // set background mode to transparent so black isn't copied
    TextOut      (xdc, pPosX, pPosY, Texte, strlen (pTexte)); // draw the text

    SurfaceBack->ReleaseDC (xdc); // release the dc

    return true;
}
开发者ID:hlemorvan,项目名称:vision-stereo,代码行数:26,代码来源:DirectDraw.cpp

示例4: main

////FUNCTIONS//////////////////
//-----------------------------------------------------------------------------
// Name: Main()
// Desc: Whwere all work is done
//-----------------------------------------------------------------------------
bool main()
{
    static SCCOLOR col;
    static UCHAR* back_buf;
    static HDC hDC;
    static int iFrames=0;
    static int x=0;

    col.b = col.r = col.g = 255;

    if(GetKeyStatus(VK_ESCAPE) == true)
        return(0);

    //Clear the surface
    if(!ClrS(lpddsSecondary,wndRect))//can't be within a lock-Unlock block or u can't blt
        return(0);

    //Write text to the Secondary surface remember to Release the DC
    ddReturnVal = lpddsSecondary->GetDC(&hDC);
    if (DDFailedCheck(ddReturnVal, "GetDC() failed", cpErrorBuf ))
    {
        if(ddReturnVal == DDERR_SURFACELOST)
        {
            lpddsSecondary->Restore();
            lpddsSecondary->GetDC(&hDC);
        }
        else
        {
            MessageBox(main_window_handle, cpErrorBuf, "main()", MB_ICONEXCLAMATION);
            return(0);
        }
    }

    static char buffer[1024];
    SetBkColor(hDC,RGB(0,0,0));
    SetBkMode(hDC,OPAQUE);
    sprintf(buffer, "Time elapsed(s)= %d", (int)(gametimer.GetStartElapsedTime()*0.001) );//0.00001666666f
    static DWORD starttime=GetTickCount();
    if( gametimer.Elapsed(starttime,(60/0.001)) )
        sprintf(buffer,"TIME!"," 1 minute");
    SetTextColor(hDC,RGB(255,255,255));
    iFrames++;
    static int FramesPerSec=0;
    FramesPerSec = iFrames/( ((int)(gametimer.GetStartElapsedTime()*0.001)+1) );
    sprintf(buffer, "Frames/s = %d", FramesPerSec);
    TextOut(hDC, 100,100, buffer, strlen(buffer));

    sprintf(buffer, "X= %d", x);
    TextOut(hDC, 100,140, buffer, strlen(buffer));
    ddReturnVal = lpddsSecondary->ReleaseDC(hDC);
    if (DDFailedCheck(ddReturnVal, "ReleaseDC() failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "main()", MB_ICONEXCLAMATION);
        return(0);
    }

    //Lock the surface for drawing
    if(!Lock(lpddsSecondary))
        return(0);

    back_buf = (UCHAR*)ddsd.lpSurface;

    //test drawing pixels
    DrawPixel(ddsd,x+200,100,col);
    DrawPixel(ddsd,x+200,101,col);
    DrawPixel(ddsd,x+200,102,col);
    DrawPixel(ddsd,x+200,103,col);
    DrawPixel(ddsd,x+200,104,col);
    DrawPixel(ddsd,x+200,105,col);
    DrawPixel(ddsd,x+200,106,col);
    DrawPixel(ddsd,x+200,107,col);
    DrawPixel(ddsd,x+200,108,col);
    x++;
    if(x>780)
        x=0;

    //test bitmap class
    for (int y=0; y < bitmap1.GetHeight(); y++)
    {
        // copy the line
        memcpy(&back_buf[100+(y+200)*ddsd.lPitch], // dest address
               &bitmap1.GetImageData()[y*bitmap1.GetWidth()*2],   // src address
               bitmap1.GetWidth()*2);                         // bytes to copy
    } // end for y

    //Unlock the surface
    if(!UnLock(lpddsSecondary))
        return(0);

    if(!Lock(Temp))
        return(0);
    back_buf = (UCHAR*)ddsd.lpSurface;
    for (int y=0; y < bitmap2.GetHeight(); y++)
    {
        // copy the line
//.........这里部分代码省略.........
开发者ID:scirelli,项目名称:testForDX7,代码行数:101,代码来源:Main.cpp

示例5: LoadBitmapImage

ALERROR CGImageCache::LoadBitmapImage (DWORD dwImageUNID, DWORD dwTransparencyUNID, DWORD dwDepthUNID, int *retiIndex)

//	LoadBitmapImage
//
//	Loads an image into the cache. This should only be called once
//	when the cache is initialized or when an image is first requested.

	{
	ALERROR error;
	HRESULT result;
	HBITMAP hBitmap;
	DDSURFACEDESC ddsd;
	BITMAP bm;
	LPDIRECTDRAWSURFACE7 pSurface;
	HDC hDC, hBitmapDC;
	HBITMAP hOldBitmap;
	HBITMAP hDepth;
	CGChannelStruct *pTrans = NULL;

	//	Load the bitmap from the image db

	if (error = m_pMediaDb->LoadBitmap(dwImageUNID, &hBitmap))
		return error;

	//	Get some info from bitmap

	GetObject(hBitmap, sizeof(bm), &bm);

	//	Create a surface of the proper size

	utlMemSet(&ddsd, sizeof(ddsd), 0);
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
	ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
	ddsd.dwWidth = bm.bmWidth;
	ddsd.dwHeight = bm.bmHeight;

	if (m_pScreen->GetDD()->CreateSurface(&ddsd, &pSurface, NULL) != DD_OK)
		{
		DeleteObject(hBitmap);
		return ERR_FAIL;
		}

	if (result = pSurface->GetDC(&hDC) != DD_OK)
		{
		pSurface->Release();
		DeleteObject(hBitmap);
		return ERR_FAIL;
		}

	//	Blt the bitmap onto the surface

	hBitmapDC = CreateCompatibleDC(NULL);
	hOldBitmap = (HBITMAP)SelectObject(hBitmapDC, hBitmap);

	BitBlt(hDC,
			0,
			0,
			bm.bmWidth,
			bm.bmHeight,
			hBitmapDC,
			0,
			0,
			SRCCOPY);

	SelectObject(hBitmapDC, hOldBitmap);
	DeleteDC(hBitmapDC);
	DeleteObject(hBitmap);

	pSurface->ReleaseDC(hDC);

	//	Load the transparency bitmap

	if (dwTransparencyUNID)
		{
		HBITMAP hTransparency;

		if (error = m_pMediaDb->LoadBitmap(dwTransparencyUNID, &hTransparency))
			{
			pSurface->Release();
			return error;
			}

		//	Convert this bitmap into an 8-bit map

		error = ConvertToChannel(hTransparency, &pTrans);
		DeleteObject(hTransparency);
		if (error)
			{
			pSurface->Release();
			return error;
			}
		}

	//	Load the depth bitmap

	if (dwDepthUNID)
		{
		if (error = m_pMediaDb->LoadBitmap(dwDepthUNID, &hDepth))
			{
//.........这里部分代码省略.........
开发者ID:Sdw195,项目名称:Transcendence,代码行数:101,代码来源:CGImageCache.cpp

示例6: CopyBitmapToSurface

HRESULT CTextureHolder::CopyBitmapToSurface(){

    // Get a DDraw object to create a temporary surface
    LPDIRECTDRAW7 pDD;
    m_pddsSurface->GetDDInterface( (VOID**)&pDD );

    // Get the bitmap structure (to extract width, height, and bpp)
    BITMAP bm;
    GetObject( m_hbmBitmap, sizeof(BITMAP), &bm );

    // Setup the new surface desc
    DDSURFACEDESC2 ddsd;
    ddsd.dwSize = sizeof(ddsd);
    m_pddsSurface->GetSurfaceDesc( &ddsd );
    ddsd.dwFlags          = DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|
                            DDSD_TEXTURESTAGE;
    ddsd.ddsCaps.dwCaps   = DDSCAPS_TEXTURE|DDSCAPS_SYSTEMMEMORY;
    ddsd.ddsCaps.dwCaps2  = 0L;
    ddsd.dwWidth          = bm.bmWidth;
    ddsd.dwHeight         = bm.bmHeight;

    // Create a new surface for the texture
    LPDIRECTDRAWSURFACE7 pddsTempSurface;
    HRESULT hr;
    if( FAILED( hr = pDD->CreateSurface( &ddsd, &pddsTempSurface, NULL ) ) )
    {
        pDD->Release();
        return hr;
    }

    // Get a DC for the bitmap
    HDC hdcBitmap = CreateCompatibleDC( NULL );
    if( NULL == hdcBitmap )
    {
        pddsTempSurface->Release();
        pDD->Release();
        return hr; // bug? return E_FAIL?
    }
    SelectObject( hdcBitmap, m_hbmBitmap );

    // Handle palettized textures. Need to attach a palette
    if( ddsd.ddpfPixelFormat.dwRGBBitCount == 8 )
    {
        LPDIRECTDRAWPALETTE  pPalette;
        DWORD dwPaletteFlags = DDPCAPS_8BIT|DDPCAPS_ALLOW256;
        DWORD pe[256];
        WORD  wNumColors     = GetDIBColorTable( hdcBitmap, 0, 256, (RGBQUAD*)pe );

        // Create the color table
        for( WORD i=0; i<wNumColors; i++ )
        {
            pe[i] = RGB( GetBValue(pe[i]), GetGValue(pe[i]), GetRValue(pe[i]) );

            // Handle textures with transparent pixels
            if( m_dwFlags & (D3DTEXTR_TRANSPARENTWHITE|D3DTEXTR_TRANSPARENTBLACK) )
            {
                // Set alpha for opaque pixels
                if( m_dwFlags & D3DTEXTR_TRANSPARENTBLACK )
                {
                    if( pe[i] != 0x00000000 )
                        pe[i] |= 0xff000000;
                }
                else if( m_dwFlags & D3DTEXTR_TRANSPARENTWHITE )
                {
                    if( pe[i] != 0x00ffffff )
                        pe[i] |= 0xff000000;
                }
            }
        }
        // Add DDPCAPS_ALPHA flag for textures with transparent pixels
        if( m_dwFlags & (D3DTEXTR_TRANSPARENTWHITE|D3DTEXTR_TRANSPARENTBLACK) )
            dwPaletteFlags |= DDPCAPS_ALPHA;

        // Create & attach a palette
        pDD->CreatePalette( dwPaletteFlags, (PALETTEENTRY*)pe, &pPalette, NULL );
        pddsTempSurface->SetPalette( pPalette );
        m_pddsSurface->SetPalette( pPalette );
        SAFE_RELEASE( pPalette );
    }

    // Copy the bitmap image to the surface.
    HDC hdcSurface;
    if( SUCCEEDED( pddsTempSurface->GetDC( &hdcSurface ) ) )
    {
        BitBlt( hdcSurface, 0, 0, bm.bmWidth, bm.bmHeight, hdcBitmap, 0, 0,
                SRCCOPY );
        pddsTempSurface->ReleaseDC( hdcSurface );
    }
    DeleteDC( hdcBitmap );

    // Copy the temp surface to the real texture surface
    m_pddsSurface->Blt( NULL, pddsTempSurface, NULL, DDBLT_WAIT, NULL );

    // Done with the temp surface
    pddsTempSurface->Release();

    // For textures with real alpha (not palettized), set transparent bits
    if( ddsd.ddpfPixelFormat.dwRGBAlphaBitMask )
    {
        if( m_dwFlags & (D3DTEXTR_TRANSPARENTWHITE|D3DTEXTR_TRANSPARENTBLACK) )
//.........这里部分代码省略.........
开发者ID:svagionitis,项目名称:Hover,代码行数:101,代码来源:textures.cpp


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