1、找到安装目录下的halcondotnet.dll
2、自己新增dlls离线程序集合文件夹
3、放入halcondotnet.dll
4、wpf程序右键引用dll
5、报错 System.Drawing.Common问题
nuget安装包 System.Drawing.Common
6、wpf使用halcondotnet.dll 程序集
<UserControl x:Class="HalconDemoTest.Modules.ModuleName.Views.ViewA"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:local="clr-namespace:HalconDemoTest.Modules.ModuleName.Views"xmlns:prism="http://prismlibrary.com/"xmlns:HalconDotNet="clr-namespace:HalconDotNet;assembly=halcondotnet"prism:ViewModelLocator.AutoWireViewModel="True"><Grid><HalconDotNet:HSmartWindowControlWPF Name="WindowControl" Width="{Binding ElementName=WidthSlider, Path=Value}"Height="600" Loaded="HSmartWindowControlWPF_Loaded"Grid.Row="1" Grid.Column="1" /></Grid> </UserControl>
using HalconDotNet; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;namespace HalconDemoTest.Modules.ModuleName.Views {/// <summary>/// Interaction logic for ViewA.xaml/// </summary>public partial class ViewA : UserControl{public ViewA(){InitializeComponent();}private void HSmartWindowControlWPF_Loaded(object sender, RoutedEventArgs e){var pictureCtrl = sender as HSmartWindowControlWPF;HImage img = new HImage("1.png");pictureCtrl.HalconWindow.DispImage(img);}} }
7、图片设置
图片 当然也可以手动放置到程序exe执行的路径中
8、显示