資源簡介
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;
- 上一篇:C#數據統計圖
- 下一篇:C#編寫的簡單web服務器(含源代碼)
評論
共有 條評論