基本信息
源码名称:C#和Halcon联合编程之按比例显示图片
源码大小:0.33M
文件格式:.rar
开发语言:C#
更新时间:2019-02-24
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
C#和Halcon联合编程图片太大时按比例显示图片
v

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 WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            HObject ho_Image;

            HTuple hv_Width, hv_Height;

            HOperatorSet.GenEmptyObj(out ho_Image);

            //dev_close_window(...);
            ho_Image.Dispose();
            HOperatorSet.ReadImage(out ho_Image, "C:/Users/dell/Desktop/KingSight/标定平面/you_master_1.bmp");
            HOperatorSet.GetImageSize(ho_Image, out hv_Width, out hv_Height);
            double ratioWidth = (1.0) * hv_Width[0].I / hWindowControl1.Width;
            double ratioHeight = (1.0) * hv_Height[0].I / hWindowControl1.Height;
            HTuple row1, column1, row2, column2;
            if (ratioWidth >= ratioHeight)
            {
                row1 = -(1.0) * ((hWindowControl1.Height * ratioWidth) - hv_Height) / 2;
                column1 = 0;
                row2 = row1   hWindowControl1.Height * ratioWidth;
                column2 = column1   hWindowControl1.Width * ratioWidth;
                HOperatorSet.SetPart(hWindowControl1.HalconWindow, row1, column1, row2, column2);
            }
            //dev_open_window(...);
            HOperatorSet.DispObj(ho_Image, hWindowControl1.HalconWindow);

        }
    }
}