mirror of
https://gitee.com/wang-yin1/wpf-visual-process-framework
synced 2026-03-02 15:50:51 +08:00
67 lines
1.9 KiB
C#
67 lines
1.9 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using VisionFrame.Base;
|
|||
|
|
|
|||
|
|
namespace ImageProcess
|
|||
|
|
{
|
|||
|
|
public class ImageShowNodeModel : NodeModelBase
|
|||
|
|
{
|
|||
|
|
public ImageShowNodeModel()
|
|||
|
|
{
|
|||
|
|
this.NodeName = "图像显示";
|
|||
|
|
|
|||
|
|
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
|||
|
|
{
|
|||
|
|
ArgName = "图像Handle",
|
|||
|
|
ArgType = "IntPtr",
|
|||
|
|
Direction = "输入",
|
|||
|
|
ValueMode = 0
|
|||
|
|
});
|
|||
|
|
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
|||
|
|
{
|
|||
|
|
ArgName = "图像宽",
|
|||
|
|
ArgType = "Int",
|
|||
|
|
Direction = "输出",
|
|||
|
|
ValueMode = 0
|
|||
|
|
});
|
|||
|
|
this.Arguments.Add(new VisionFrame.Base.Models.NodeArgModel
|
|||
|
|
{
|
|||
|
|
ArgName = "图像高",
|
|||
|
|
ArgType = "Int",
|
|||
|
|
Direction = "输出",
|
|||
|
|
ValueMode = 0
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void Execute(IFlowContext flowContext)
|
|||
|
|
{
|
|||
|
|
if (this.Arguments[0].ArgValue == null)
|
|||
|
|
throw new Exception("图像Handle参数未配置");
|
|||
|
|
|
|||
|
|
var am = flowContext.ArgumentList
|
|||
|
|
.FirstOrDefault(a => a.ArgName == this.Arguments[0].ArgValue.ToString());
|
|||
|
|
|
|||
|
|
if (am.ArgType != this.Arguments[0].ArgType)
|
|||
|
|
throw new Exception("参数配置异常!类型不匹配");
|
|||
|
|
|
|||
|
|
if (IntPtr.TryParse(am.Value.ToString(), out IntPtr img_handler))
|
|||
|
|
{
|
|||
|
|
//
|
|||
|
|
//Bitmap bitmap = Bitmap.FromHbitmap(img_handler);
|
|||
|
|
|
|||
|
|
|
|||
|
|
//bitmap.Width
|
|||
|
|
//bitmap.Height
|
|||
|
|
|
|||
|
|
flowContext.ShowImage(img_handler);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
throw new Exception("图像Handle数据无效");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|