I'm looking to speed up a Bitmap displaying program. It's not dreadfully slow, I just think it could be faster. I run it in a Win32 environment. Here's the code:
void load(LPCWSTR file, int i) {
hBitmap[i] = (HBITMAP)::LoadImage(NULL, file, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE);
GetObject(hBitmap[i], sizeof(BITMAP), (LPSTR)&hSize[i]);
}
void newBit(int i, int x, int y, HDC hdc) {
BITMAP Bitmap = hSize[i];
HBITMAP hBit = hBitmap[i];
HDC hDCBits = CreateCompatibleDC(hdc);
SelectObject(hDCBits, hBit);
StretchBlt(hdc, x, y, Bitmap.bmWidth, Bitmap.bmHeight,
hDCBits, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, SRCCOPY);
DeleteDC(hDCBits);
}
I run the "Load" function in the beginning, and I'm okay with how long it takes. I run the newBit function whenever in the program that I need to. I specifically use the stretchBlt command because I need the resizing capability. Any insight into what I'm doing wrong and what I could improve would be appreciated.