|
各位大侠你们好,麻烦看一看我这个函数 Bitmap_Surface
LPDIRECTDRAWSURFACE7 Bitmap_Surface(int nResID)
{
LPDIRECTDRAWSURFACE7 lpdd;
HDC hdc;
HBITMAP hbitmap;
BITMAP bmp;
hbitmap=(HBITMAP)LoadImage(g_hInstance,MAKEINTRESOURCE(nResID),IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION);
if (!hbitmap) return NULL;
GetObject(hbitmap,sizeof(BITMAP),&bmp);
DDSURFACEDESC2 ddsd;
InitDesc(ddsd);
ddsd.dwFlags =DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT ;
ddsd.ddsCaps.dwCaps =DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth =bmp.bmWidth ;
ddsd.dwHeight =bmp.bmHeight ;
if (lpDD->CreateSurface (&ddsd,&lpdd,NULL)!=DD_OK)
{
DeleteObject(hbitmap);
return NULL;
}else{
lpdd->GetDC(&hdc);
HDC hSrcDC = CreateCompatibleDC(hdc);
SelectObject(hSrcDC,hbitmap);
BitBlt(hdc,0,0,bmp.bmWidth ,bmp.bmHeight ,hSrcDC,0, 0, SRCCOPY);
lpdd->ReleaseDC (hdc);
DeleteDC(hSrcDC);
}
DeleteObject(hbitmap);
return lpdd;
}
使用方法:
void TestFlip()
{
LPDIRECTDRAWSURFACE7 lpdd;
lpdd=Bitmap_Surface(BACKGROUND2);
lpDDSBack->BltFast (0,0,lpdd,NULL,DDBLTFAST_WAIT);
lpDDSPrimary->Flip (0,DDFLIP_WAIT);
}
这个函数运行正常,我想问的是:
这个函数的效率(速度,性能)是不是很低,请问大家是使用什么方法在游戏中帖图(读图)的?
请大家指教一下,谢谢! |
|