資源簡(jiǎn)介
halcon自帶的控件感覺(jué)沒(méi)picturebox好用,文檔簡(jiǎn)述了通過(guò)鼠標(biāo)滾輪事件在picturebox上縮放圖片,實(shí)際就是setpart圖片,同理移動(dòng)也是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;
????????????????}
????????????????//縮放后的長(zhǎng)度
????????????????double?Lr?=?(ImagePart_X2?-?ImagePart_X1)?*?SC;
????????????????double?Lc?=?(ImagePart_Y2?-?ImagePart_Y1)?*?SC;
評(píng)論
共有 條評(píng)論