bool LoadImage(LPDIRECTDRAWSURFACE s, LPSTR szImage,int width, int height, POINT p) {
HBITMAP hbm;
HDC hdcImage = NULL;
HDC hdcSurf = NULL;
bool bReturn = FALSE;
DDSURFACEDESC ddsd;
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
s->GetSurfaceDesc(&ddsd);
ddsd.dwWidth = width;
ddsd.dwHeight = height;
hbm = (HBITMAP)LoadImage(NULL,szImage,IMAGE_BITMAP, ddsd.dwWidth, ddsd.dwHeight, LR_LOADFROMFILE / LR_CREATEDIBSECTION );
hdcImage = CreateCompatibleDC(NULL);
SelectObject(hdcImage, hbm);
s->GetDC(&hdcSurf);
BitBlt(hdcSurf, p.x, p.y, ddsd.dwWidth, ddsd.dwHeight, hdcImage, 0, 0, SRCCOPY);
bReturn = TRUE;
s->ReleaseDC(hdcSurf);
DeleteDC(hdcImage);
DeleteObject(hbm);
return bReturn;
}
any help would be greatly appreciated.
help with code
could someone help me modify this code to allow transparency... i would like the transparent color to be 255,0,255. this is for 16bit color...
-uncreativpresidenthalosoft, inc.halosoft.hypermart.net
I don''t think you should edit that code... Why don''t you set a colorkey to your destination surface (maybe back buffer) and blit surface that contains image to destination surface...? Use lpDDSurface->SetColorKey() to set your colorkey (I think DirectX manual or examples can help you how to use it). You can set colorkey to your surface that contains image, too if you''re sure that your display card supports it.
Oh... Don''t forget to set the flag DDBLT_DSTCOLORKEY or DDBLT_SRCCOLORKEY when you blit surface that contains image to destination surface, too...
Hope it helps...
Oh... Don''t forget to set the flag DDBLT_DSTCOLORKEY or DDBLT_SRCCOLORKEY when you blit surface that contains image to destination surface, too...
Hope it helps...

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement