MFC利用Halcon显示图片

工具说明:Halcon10,VS2013,利用Picture Control控件进行图片显示

包含的头文件:

#include "HalconCpp.h"

using namespace Halcon;

需要包含的库路径:halconcpp.lib

void CHalconWndShowDlg::OnBnClickedOpen()
{
	HTuple HWindowID;
	HTuple newHWindowID;
	CRect rect;
	HTuple ImageWidth;
	HTuple ImageHeight;

	CWnd* pWnd = GetDlgItem(IDC_STATIC);  //IDC_STATIC为Picture Control控件的ID
	HWindowID = (Hlong)pWnd->m_hWnd;
	pWnd->GetWindowRect(&rect);
	
	open_window(0, 0, rect.Width(), rect.Height(), HWindowID, "visible", "", &newHWindowID);

	Hobject hImage;
	read_image(&hImage, "./Product.jpg");
	get_image_pointer1(hImage,NULL,NULL,&ImageWidth,&ImageHeight);
	set_part(newHWindowID,0,0,ImageHeight-1,ImageWidth-1);
	disp_obj(hImage, newHWindowID);
}

你可能感兴趣的:(C++)