ok now i got the loadbitmap() and copybitmap()
how do make use of them to load game intro screens? and r they alone sufficient?
DDLoadBitmap(IDirectDraw7 *lpdd, LPCSTR szBitmap, int dx, int dy)
{
HBITMAP hbm;
BITMAP bm;
DDSURFACEDESC2 ddsd;
IDirectDrawSurface7 *lpdds;
//
// This is the Win32 part.
// Try to load the bitmap as a resource.
// If that fails, try it as a file.
//
hbm = (HBITMAP)LoadImage(
GetModuleHandle(NULL), szBitmap,
IMAGE_BITMAP, dx, dy, LR_CREATEDIBSECTION);
if (hbm == NULL)
hbm = (HBITMAP)LoadImage(
NULL, szBitmap, IMAGE_BITMAP, dx, dy,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if (hbm == NULL)
return NULL;
//
// Get the size of the bitmap.
//
GetObject(hbm, sizeof(bm), &bm);
//
// Now, return to DirectX function calls.
// Create a DirectDrawSurface for this bitmap.
//
ZeroMemory(&ddsd, sizeof(ddsd));
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 (lpdd->CreateSurface(&ddsd, &lpdds, NULL) != DD_OK)
return NULL;
DDCopyBitmap(lpdds, hbm, 0, 0, 0, 0);
DeleteObject(hbm);
return (1);
}
DDCopyBitmap(IDirectDrawSurface7 *lpdds, HBITMAP hbm,
int x, int y, int dx, int dy)
{
HDC hdcImage;
HDC hdc;
BITMAP bm;
DDSURFACEDESC2 ddsd;
HRESULT hResult;
if (hbm == NULL || lpdds == NULL)
return E_FAIL;
// Make sure this surface is restored
lpdds->Restore();
// Select bitmap into a memoryDC so we can use it.
hdcImage = CreateCompatibleDC(NULL);
SelectObject(hdcImage, hbm);
// Get the size of the bitmap
GetObject(hbm, sizeof(bm), &bm);
// Use this size unless overridden
dx = dx == 0 ? bm.bmWidth : dx;
dy = dy == 0 ? bm.bmHeight : dy;
// Get the size of the surface
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT|DDSD_WIDTH;
lpdds->GetSurfaceDesc(&ddsd);
if ((hResult = lpdds->GetDC(&hdc)) == DD_OK)
{
StretchBlt(hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage, x, y,
dx, dy, SRCCOPY);
lpdds->ReleaseDC(hdc);
}
DeleteDC(hdcImage);
return hResult;
}
[edited by - edwinnie on April 28, 2002 10:04:55 AM]