I am making a BMP loader. I have a question. I already have the "Browse..." button, but how do I LOAD the BMP. I need an example for once I get the name of the selected file. Any help is appreciated!
Printable View
I am making a BMP loader. I have a question. I already have the "Browse..." button, but how do I LOAD the BMP. I need an example for once I get the name of the selected file. Any help is appreciated!
www.google.com will answer this question without anyone having to write it out here.
search first, read someone else's code and give it a go.. when you have problems... post again.
U.
Use LoadImage().
Tho I'm away from my computer so not totally sure about the arguments being in the right place, in fact it's been several weeks away from the compiler so your going to have to correct the errors yourself......play with it...
...That's the basic idea anyway. Oh and of course don't actually declare the variables in the message loop, I used it for brevity...Code:PAINTSTRUCT ps;
case WM_CREATE:
int screenX = GetSystemMetrics(SM_CXSCREEN);
int screenY = GetSystemMetrics(SM_CYSCREEN);
HDC dc = GetDC(hwnd);
HDC hdc = CreateCompatibleDC(dc);
HBITMAP b = CreateCompatibleBitmap(dc);
SelectObject(hdc, b);
PatBlt(hdc, screenX, screenY, PATCOPY);
HBITMAP bm = (HBITMAP)LoadImage("bmp.bmp", ??, ??, IMAGE_BITMAP, LR_LOADFROMFILE, hThisInstance);
HDC bmdc = CreateCompatibleDC(dc);
SelectObject(dc, bmdc);
PatBlt(bmdc, screenX, screenY, PATCOPY);
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
BitBlt(hdc <-- bmdc); // Obviously not a literal function call...
EndPaint(hwnd, &ps);
....good luck!
Don't forget to free, with DeleteDC() / ReleaseDC() / DeleteObject() ect, all that mem you are allocating with the Create??() and CreateCompatible??() functions.