Zoom in using picture control
I'm have a bitmap that's about 4000x2000. But I want to put it all into a picture
control. I attempted to use stretchBlt() to shrink it. But it did not work. What am
I doing wrong?
Code:
HBITMAP originalImage = CreateDIBitmap(m_picture1.GetDC()->m_hDC,
m_bmiHeader,
CBM_INIT,
(unsigned short *)m_OriginalBits,
m_bmiInfo,
DIB_RGB_COLORS);
// I want to use stretchBlt to put the bitmap (OriginalBits) into a smaller m_picture1,
// what should I from the target and source hDC? I'm very confused.
bool rc = StretchBlt(GetDC()->m_hDC,
0,
0,
FRAMEWIDTH,
FRAMEHEIGHT,
GetDC()->m_hDC,
0,
0,
m_bmiHeader->biWidth,
m_bmiHeader->biHeight,
SRCCOPY); */
m_picture1.SetBitmap(originalImage);
Re: Zoom in using picture control
Where do you call this code from?
Re: Zoom in using picture control
Quote:
Originally Posted by
VictorN
Where do you call this code from?
I have dialog and that dialog contains a picture control and a few buttons,
did I do anything wrong with the source size in StretchBlt() or anything to that
nature? I'm stumped.
Code:
BOOL CImgView::OnInitDialog()
{
CDialogEx::OnInitDialog();
SetWindowPos(&wndBottom,
0,
0,
FRAMEWIDTH + 140,
FRAMEHEIGHT + 60,
SWP_NOMOVE | SWP_NOZORDER);
m_bits = (unsigned char*)malloc(sizeof(FRAMEHEIGHT * FRAMEWIDTH * 3));
//Initialize the size of the image as the same as that of the frame
m_ImgWidth = FRAMEWIDTH;
m_ImgHeight = FRAMEHEIGHT;
m_picture1.ModifyStyle(0, SS_BITMAP | SS_CENTERIMAGE);
CRect rect1;
GetWindowRect(&rect1);
m_picture1.SetWindowPos(&wndBottom,
120,
10,
FRAMEWIDTH,
FRAMEHEIGHT,
SWP_NOZORDER);
HBITMAP originalImage = CreateDIBitmap(m_picture1.GetDC()->m_hDC,
m_bmiHeader,
CBM_INIT,
(unsigned short *)m_OriginalBits,
m_bmiInfo,
DIB_RGB_COLORS);
bool rc = StretchBlt(GetDC()->m_hDC,
0,
0,
FRAMEWIDTH,
FRAMEHEIGHT,
GetDC()->m_hDC,
0,
0,
m_bmiHeader->biWidth,
m_bmiHeader->biHeight,
SRCCOPY);
m_picture1.SetBitmap(originalImage);
return TRUE;
}
Re: Zoom in using picture control
Why do you call SetBitmap after you draw the bitmap ? You can find something to help you on http://www.functionx.com/visualc/ ... there, you can see how to draw a bitmap ...