Loading Bitmap to the surface....
Ok so Im working on Tetris..I use the Win32 Func LoadImage to load the bitmap but, what do i use to get it from memory to the surface? Mind you im using DDraw not DXGraphics no 3d card in this comp...I know BitBlt will transfer from surface to surface but i dont think it will take the bmp from memory to the surface.
Any ideas, any help is appreciated.
You can get access to bitmap bits using GetObject function and BITMAP structure.
---visit #directxdev on afternet <- not just for directx, despite the name
HDC Mem = NULL; HBITMAP NewBitmap = NULL;HBITMAP OldBitmap = NULL;HRESULT hr; HDC Hdc=GetDC(WindowHandle);Mem = CreateCompatibleDC(Hdc); NewBitmap = (HBITMAP)LoadImage(NULL,Filename,IMAGE_BITMAP,0,0,LR_LOADFROMFILE); OldBitmap = (HBITMAP)SelectObject(Mem,NewBitmap); BITMAP Bitmap; GetObject(NewBitmap,sizeof(BITMAP),(LPVOID)&Bitmap); DDSURFACEDESC2 DDSD; memset(&ddsd,0,sizeof(DDSURFACEDESC2)); DDSD.dwSize = sizeof(DDSURFACEDESC2); DDSD.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;DDSD.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY;DDSD.dwWidth = Bitmap.bmWidth; DDSD.dwHeight = Bitmap.bmHeight; DirectDraw->CreateSurface(&DDSD,&OffscreenSurface,NULL); HDC SurfaceHDC; OffscreenSurface->GetDC(&SurfaceHDC); BitBlt(SurfaceHDC,0,0,Bitmap.bmWidth,Bitmap.bmWidth,Mem,0,0, SRCCOPY);OffscreenSurface->ReleaseDC(SurfaceHDC);
Ballistic Programs
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement