本文介绍了如何使用Stretchblt获取调整位图图像大小的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的mfc应用程序中,我有一个对话框和一个图片控件(245,26,204,184),其ID为IDC_pic.
我的代码是
SecondDlg.cpp
In my mfc application I have dialog box and a picture control(245,26,204,184) its id is IDC_pic.
My code is
SecondDlg.cpp
void CSecondDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_pic, m_nHeight); //m_nHeight is CStatic object
}
void SecondDlg::OnBnClickedButton1()
{
if(m_flag && m_hBmp)
{
capEditCopy(hMyWindow);
OpenClipboard();
m_hBmp = (HBITMAP)::GetClipboardData(CF_BITMAP);
m_hBmp = (HBITMAP)::GetClipboardData(CF_BITMAP);
m_nHeight.SetBitmap(m_hBmp); //here working fine
BITMAP bm;
GetObject(m_hBmp,sizeof(BITMAP),&bm);
HDC TempHDC,TempHDC1;
TempHDC1 = ::CreateCompatibleDC(NULL);
SelectObject(TempHDC1,m_hBmp);
CRect c1(245,26,24,14),c2(245,26,204,184);
int rest=::StretchBlt(TempHDC1,550,157,50,50, TempHDC1, c2.left,c2.top,bm.bmWidth,bm.bmHeight, SRCCOPY );
hOldBitmap2=CreateCompatibleBitmap(TempHDC1,204,184);
GetObject(hOldBitmap2,sizeof(BITMAP),&bm);
m_nHeight.SetBitmap(hOldBitmap2);
DeleteDC(TempHDC);
CloseClipboard();
}
}
我在SecondDlg上具有图片控件(ID为IDC_pic).
现在IDC_pic出现黑屏了.
I have picture control(id is IDC_pic) on SecondDlg.
Now IDC_pic got black screen.
推荐答案
这篇关于如何使用Stretchblt获取调整位图图像大小的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!