文档详情

Haclcon在C#中实现鼠标的缩放和平移的代码和讲解.docx

发布:2017-05-24约2.56千字共3页下载文档
文本预览下载声明
本人haungbing114 发表于halcon学习网Halcon的控件滑轮事件:放缩代码:// 设定图像的窗口显示部分??? ? ? ?private double zoom_beginX, zoom_beginY, zoom_width, zoom_heigth;??? ? ? ?// 获取图像的当前显示部分??? ? ? ?private double current_beginX, current_beginY, current_width, current_heigth;??? ? ? ?//放大缩小图像??? ? ? ?public void pictureZoom(int delta, double centerX, double centerY)??? ? ? ?{??? ? ? ? ? ?//??? ? ? ? ? ?hv_WinHandleShow.HalconWindow.ClearWindow();??? ? ? ? ? ?//放大图片:delta0??? ? ? ? ? ?if (delta 0)??? ? ? ? ? ?{??? ? ? ? ? ? ? ?zoom_width = current_width * 0.8d;??? ? ? ? ? ? ? ?zoom_heigth = current_heigth * 0.8d;??? ? ? ? ? ? ? ?zoom_beginX = 0;??? ? ? ? ? ? ? ?zoom_beginY = 0;??? ? ? ? ? ? ? ?if (centerX - zoom_width / 2d 0)??? ? ? ? ? ? ? ? ? ?zoom_beginX = centerX - zoom_width / 2d;??? ? ? ? ? ? ? ?if (centerY - zoom_heigth / 2d 0)??? ? ? ? ? ? ? ? ? ?zoom_beginY = centerY - zoom_heigth / 2d;??? ? ? ? ? ? ? ?if (hv_width[0].I centerX + zoom_width / 2d)??? ? ? ? ? ? ? ? ? ?zoom_beginX = (double)hv_width[0].I - zoom_width;??? ? ? ? ? ? ? ?if (hv_height[0].I centerY + zoom_heigth / 2d)??? ? ? ? ? ? ? ? ? ?zoom_beginY = (double)hv_height[0].I - zoom_heigth;??? ? ? ? ? ? ? ?//hv_WinHandleShow.ImagePart = new System.Drawing.Rectangle((int)zoom_beginX, (int)zoom_beginY, (int)zoom_width, (int)zoom_heigth);??? ? ? ? ? ?}??? ? ? ? ? ?else??? ? ? ? ? ?{??? ? ? ? ? ? ? ?zoom_width = current_width / 0.8d;??? ? ? ? ? ? ? ?zoom_heigth = current_heigth / 0.8d;??? ? ? ? ? ? ? ?zoom_beginX = 0;??? ? ? ? ? ? ? ?zoom_beginY = 0;??? ? ? ? ? ? ? ?if (centerX - zoom_width / 2d 0)??? ? ? ? ? ? ? ? ? ?zoom_beginX = centerX - zoom_width / 2d;??? ? ? ? ? ? ? ?if (centerY - zoom_heigth / 2d 0)??? ? ? ? ? ? ? ? ? ?zoom_beginY = centerY - zoom_heigth / 2d;??? ? ? ? ? ? ? ?if (hv_width[0].I centerX + zoom_width / 2d)??? ? ? ? ? ? ? ? ? ?zoom_beginX = (double)hv_width[0].I - zoom_width;??? ? ? ? ? ? ? ?if (hv_height[0].I centerY + zoom_heigth / 2d)??? ? ? ? ? ? ? ? ? ?zoom_beginY = (double)hv_height[0].I - zoom_heigth;
显示全部
相似文档