• 大小: 1.09MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-17
  • 语言: C#
  • 标签: Halcon  C#  

资源简介

Halcon的HWindowControl控件在WinForm程序中的使用介绍

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HalconDotNet;

namespace ShowImage
{
    public partial class MainForm : Form
    {
        HImage hoImage = new HImage();
        HWindow hoWindow = new HWindow();

        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender EventArgs e)
        {
            hoWindow = hWindowControl1.HalconWindow;

            textBox_Width.Text = hWindowControl1.ImagePart.Width.ToString();
            textBox_Height.Text = hWindowControl1.ImagePart.Height.ToString();

            button_SetImagePart.Enabled = false;
        }

        private void button_OpenImage_Click(object sender EventArgs e)
        {
            try
            {
                hoImage.ReadImage(“lena.png“);
            }
            catch (HalconException ex)
            {
                MessageBox.Show(“Read Image Unsuccessful!!!\n“ + ex.Message);
                return;
            }

            hoWindow.ClearWindow();
            hoImage.DispObj(hoWindow);

            button_SetImagePart.Enabled = true;
        }

        private void button_SetImagePart_Click(object sender EventArgs e)
        {
            int dWidth = Convert.ToInt32(textBox_Width.Text.Trim());
            int dHeight = Convert.ToInt32(textBox_Height.Text.Trim());
            if (dWidth > 0 && dHeight > 0)
            {
                hoWindow.ClearWindow();
                hoWindow.SetPart(0 0 dHeight - 1 dWidth - 1);
                hoImage.DispObj(hoWindow);
            }
            else
            {
                MessageBox.Show(“The width of ImagePart is <= 0 or The height of ImagePart is <= 0“);
            }
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-12-04 17:09  ShowImage\
     目录           0  2016-12-04 17:10  ShowImage\ShowImage\
     文件         869  2016-12-04 17:09  ShowImage\ShowImage.sln
     文件       18944  2016-12-04 20:43  ShowImage\ShowImage.suo
     文件         117  2016-12-04 17:10  ShowImage\ShowImage\app.config
     目录           0  2016-12-04 17:29  ShowImage\ShowImage\bin\
     目录           0  2016-12-04 17:29  ShowImage\ShowImage\bin\Debug\
     文件     1279544  2014-11-15 02:27  ShowImage\ShowImage\bin\Debug\halcondotnet.dll
     文件     4074746  2014-11-15 01:07  ShowImage\ShowImage\bin\Debug\halcondotnet.xml
     文件      473831  2013-11-13 17:44  ShowImage\ShowImage\bin\Debug\lena.png
     文件       11264  2016-12-04 18:35  ShowImage\ShowImage\bin\Debug\ShowImage.exe
     文件         117  2016-12-04 17:10  ShowImage\ShowImage\bin\Debug\ShowImage.exe.config
     文件       26112  2016-12-04 18:35  ShowImage\ShowImage\bin\Debug\ShowImage.pdb
     文件       11608  2016-12-04 18:46  ShowImage\ShowImage\bin\Debug\ShowImage.vshost.exe
     文件         117  2016-12-04 17:10  ShowImage\ShowImage\bin\Debug\ShowImage.vshost.exe.config
     目录           0  2016-12-04 17:09  ShowImage\ShowImage\bin\Release\
     文件        1939  2016-12-04 18:35  ShowImage\ShowImage\MainForm.cs
     文件        6681  2016-12-04 17:44  ShowImage\ShowImage\MainForm.Designer.cs
     文件        5817  2016-12-04 17:44  ShowImage\ShowImage\MainForm.resx
     目录           0  2016-12-04 17:09  ShowImage\ShowImage\obj\
     目录           0  2016-12-04 17:09  ShowImage\ShowImage\obj\x86\
     目录           0  2016-12-04 18:35  ShowImage\ShowImage\obj\x86\Debug\
     文件        7521  2016-12-04 17:11  ShowImage\ShowImage\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6516  2016-12-04 18:35  ShowImage\ShowImage\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件        4860  2016-12-04 17:44  ShowImage\ShowImage\obj\x86\Debug\ResGen.read.1.tlog
     文件         934  2016-12-04 17:44  ShowImage\ShowImage\obj\x86\Debug\ResGen.write.1.tlog
     文件         939  2016-12-04 18:46  ShowImage\ShowImage\obj\x86\Debug\ShowImage.csproj.FileListAbsolute.txt
     文件       11264  2016-12-04 18:35  ShowImage\ShowImage\obj\x86\Debug\ShowImage.exe
     文件         180  2016-12-04 17:44  ShowImage\ShowImage\obj\x86\Debug\ShowImage.MainForm.resources
     文件       26112  2016-12-04 18:35  ShowImage\ShowImage\obj\x86\Debug\ShowImage.pdb
     文件         180  2016-12-04 17:20  ShowImage\ShowImage\obj\x86\Debug\ShowImage.Properties.Resources.resources
............此处省略10个文件信息

评论

共有 条评论