Is there any Win32 API function that will allow me to load a subsection of a bitmap (specifying width, height, and x,y) without resorting to directly manipulating the bitmapped data?
Is there any Win32 API function that will allow me to load a subsection of a bitmap (specifying width, height, and x,y) without resorting to directly manipulating the bitmapped data?
Get the current screen DC. Create a memory DC which is compatible with the screen DC. Create a compatible bitmap. Load your bitmap into the memory DC and use BitBlt() to copy whichever rectangles you want.
Lookup GetDC(), CreateCompatibleDC(), CreateCompatibleBitmap(), SelectObject(), BitBlt(), ReleaseDC(), DeleteDC(), DeleteObject().
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
Adrian is right but you need two DC's. One for the final image and one temp.
If you want you can create the DC as Adrian says, then just select the BMP into it (catching the return) rather than creating a compatible bitmap.
Then use BitBlt() or the less satisfactory StretchBlt() to copy the relevent section to your framebuffer DC.
Reselect the original BMP and clean up the GDI's.
I find GetObject() is handy to find the dimensions of the BMP.
GetObject(hBMP,sizeof(BITMAP),&BMP);
iWidth=BMP.bmWidth;// ect
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill