Halcon+MFC圖像顯示

1.VS中配置好Halcon(這裏不做說明)

2.添加一個按鈕和一個靜態文本控件(這裏不做說明)

3.主要代碼:

void CHalcon_MFCDlg::OnBnClickedButton1()
{
	 //TODO: 在此添加控件通知處理程序代碼
	Hobject  ho_Image;
	HTuple HWindowID;
	CRect Rect;
	HTuple m_HWindowID;
	HTuple m_ImageWidth,m_ImageHeight;

	CWnd * pWnd = GetDlgItem( IDC_STATIC);
	HWindowID = (Hlong)pWnd->m_hWnd;//獲取父窗口句柄
	pWnd->GetWindowRect(&Rect);
	open_window(0,0,Rect.Width(),Rect.Height(),HWindowID,"","",&m_HWindowID );
	read_image(&ho_Image, "11.jpg");
	get_image_size(ho_Image, &m_ImageWidth, &m_ImageHeight); 
	set_part(m_HWindowID,0,0,m_ImageHeight-1,m_ImageWidth-1);
	disp_obj(ho_Image, m_HWindowID);
}
4.操作:點擊“顯示圖片”,效果如下


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章