• 大小: 3KB
    文件类型: .cs
    金币: 1
    下载: 0 次
    发布日期: 2021-05-12
  • 语言: C#
  • 标签: halcon  

资源简介

halcon自带的控件感觉没picturebox好用,文档简述了通过鼠标滚轮事件在picturebox上缩放图片,实际就是setpart图片,同理移动也是setpart图片部分,仅供参考。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HalconDotNet;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms; 

namespace DalsaCameral
{

public static void OpenWindows(IntPtr PictureHandle int PictureBoxWidth int PictureBoxHeight)
        {
            HTuple Pwidth = PictureBoxWidth;
            HTuple Pheight = PictureBoxHeight;
            HOperatorSet.OpenWindow(0 0 Pwidth Pheight PictureHandle “visible“ ““ out hv_ExpDefaultWinHandle);
            pictureBox_With = PictureBoxWidth;
            pictureBox_Height = PictureBoxHeight;
        }

static HTuple ImagePart_X1 ImagePart_Y1 ImagePart_X2 ImagePart_Y2;

      public static void zoomImage(bool ScanlHobject ho_ImageRote)
        {
            
                HTuple r1 c1 b;
                HOperatorSet.GetMposition(hv_ExpDefaultWinHandle out r1 out c1 out b);

                double d1 = r1 d2 = c1;
                //缩放前的比例
                double crux = (d1 - ImagePart_X1) / (ImagePart_X2 - ImagePart_X1);
                double cruy = (d2 - ImagePart_Y1) / (ImagePart_Y2 - ImagePart_Y1);


                double SC = 1;
                if (Scanl)
                {
                    SC = 0.95;
                }
                else
                {
                    SC = 1.05;
                }
                //缩放后的长度
                double Lr = (ImagePart_X2 - ImagePart_X1) * SC;
                double Lc = (ImagePart_Y2 - ImagePart_Y1) * SC;

评论

共有 条评论