case WM_INITDIALOG:
{
BITMAP bm;
hBitmap = (HBITMAP)LoadImage(0,"page2.bmp",IMAGE_BITMAP,
0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
} break;
case WM_PAINT:
{
// Just a note, never use a MessageBox from inside WM_PAINT
// The box will cause more WM_PAINT messages and you'll probably end up
// stuck in a loop
BITMAP bm;
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
HDC hdcMem = CreateCompatibleDC(hdc);
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hBitmap);
GetObject(hBitmap, sizeof(bm), &bm);
//BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
StretchBlt(
hdc,
100,
0,
bm.bmWidth * 2,
bm.bmHeight * 2,
hdcMem,
50,
0,
bm.bmWidth,
bm.bmHeight,
SRCCOPY);
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
EndPaint(hWnd, &ps);
}
Need help with StretchBlt
okay, so i've got my image working and loading... now i need to make it so that the image appears the same size as the dialog when i run the program and so that it resizes whenever i maximize the program...
Here is what I have:
Once again, no links please. I've gone all over MSDN, so that certainly won't help.
in general what you do is:
RECT rect;
GetClientRect(hWnd, &rect);
that gets you the dimensions of your window. then you
int windowWidth = rect.right - rect.left;
int windowHeight = rect.bottom - rect.top;
then you use StretchBlt to stretch the bitmap to those dimensions.
i forgot how to use StretchBlt, but i think in your code you know
how to use it, ur just having trouble find what dimensions to
resize the bitmap to right?
RECT rect;
GetClientRect(hWnd, &rect);
that gets you the dimensions of your window. then you
int windowWidth = rect.right - rect.left;
int windowHeight = rect.bottom - rect.top;
then you use StretchBlt to stretch the bitmap to those dimensions.
i forgot how to use StretchBlt, but i think in your code you know
how to use it, ur just having trouble find what dimensions to
resize the bitmap to right?
ha ha ha that's pretty cute u put that comment about
MessageBox and WM_PAINT. newbieeeee :P:P:P:P!!!! j/k
MessageBox and WM_PAINT. newbieeeee :P:P:P:P!!!! j/k
Lol...
okay so it works initially, but the images colors are all messed up and i can make the image big when i first maximize the window, but when i make the window small, the image just stays the same size.
okay so it works initially, but the images colors are all messed up and i can make the image big when i first maximize the window, but when i make the window small, the image just stays the same size.
where are you putting your call to GetClientRect?
RECT rect;
GetClientRect(hWnd, &rect);
int windowWidth = rect.right - rect.left;
int windowHeight = rect.bottom - rect.top;
should be right b4 your call to StrecthBlt. post your new code. also what kind of bitmap is page2.bmp? 24-bit? 32-bit? 8-bit or some other palette format?
RECT rect;
GetClientRect(hWnd, &rect);
int windowWidth = rect.right - rect.left;
int windowHeight = rect.bottom - rect.top;
should be right b4 your call to StrecthBlt. post your new code. also what kind of bitmap is page2.bmp? 24-bit? 32-bit? 8-bit or some other palette format?
and you are using
?
you have to be really careful if you decide to modify the (x,y) source and destination values. kind of hard to explain them without drawing a picture. unless i need to extract only a portion of the image, i leave those values at 0.
StretchBlt( hdc, 0, 0, windowWidth, // i may have these values reversed (been long time he he he) windowHeight, hdcMem, 0, 0, bm.bmWidth, // i may have these values reversed bm.bmHeight, SRCCOPY);
?
you have to be really careful if you decide to modify the (x,y) source and destination values. kind of hard to explain them without drawing a picture. unless i need to extract only a portion of the image, i leave those values at 0.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement