首页 > 代码库 > 解决问题3:大图片显示不匹配
解决问题3:大图片显示不匹配
Hlong MainWndID =(Hlong) m_hWnd;
CWnd * pWnd = GetDlgItem( IDC_STATIC);
open_window(0,0, Width/2, Height/2,MainWndID,"visible","",&WindowHandle);
改为:
CRect rect;
CWnd * pWnd = GetDlgItem( IDC_STATIC);
Hlong MainWndID = (Hlong)pWnd->m_hWnd;//获取父窗口句柄
pWnd->GetWindowRect(&rect);
open_window(0,0, rect.Width(), rect.Height(),MainWndID,"visible","",&WindowHandle);
总的代码如下:
void CfirstpageDlg::OnBnClickedButtonShowimage()
{
using namespace Halcon;
// Local iconic variables
Hobject Image;
// HTuple HWindowID;
CRect rect;
CWnd * pWnd = GetDlgItem( IDC_STATIC);
Hlong MainWndID = (Hlong)pWnd->m_hWnd;//获取父窗口句柄
pWnd->GetWindowRect(&rect);
// Local control variables
HTuple Pointer, Type, Width, Height, WindowHandle;
read_image(&Image, "C:/Users/Hou/Documents/Tencent Files/458927028/FileRecv/1.bmp");
get_image_pointer1(Image, &Pointer, &Type, &Width, &Height);
set_window_attr("background_color","black");
open_window(0,0, rect.Width(), rect.Height(),MainWndID,"visible","",&WindowHandle);
disp_obj(Image, WindowHandle);
}
图像显示如下:
解决问题3:大图片显示不匹配