按照以下步骤创建并运行一个程序,将图像添加到Visual Studio中的LEADTOOLS ImageViewer对象。
在“解决方案资源管理器窗口中,右键单击参考文献"文件夹并选择"添加引用…从上下文菜单。在“添加引用…对话框中,选择浏览"标签并浏览到。net的领先技术"C: \ LEADTOOLS22 \ Bin \ DotNet4 \ Win32文件夹,然后选择以下dll:
集MainWindow.xaml到水平拆分,以便查看XAML代码。的源代码中插入XAML代码片段MainWindow.xaml.所提供的源代码旨在用Visual Studio和Expression Blend构建应用程序。
<窗口xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns: x = " http://schemas.microsoft.com/winfx/2006/xaml "
x: Class = " ImageViewerItems。主窗口”
x: Name = "窗口"
Title =“ImageViewerItems”
宽度= " 640 "
身高= " 480 "
xmlns: Leadtools_Controls_Wpf = " clr-namespace: Leadtools.Controls;装配= Leadtools.Controls.Wpf”>
<网格x: Name = " LayoutRoot ">
<Leadtools_Controls_Wpf:ImageViewer x:Name="_imageList" Margin="124,132,205,124" Loaded="ImageViewer_Loaded"/>
</网格>
</窗口>
打开文件后面的代码MainWindow.xaml.cs,删除该文件中的默认代码,并将其全部替换为以下代码。
使用先;
使用System.Windows;
使用Leadtools;
使用Leadtools.Codecs;
使用Leadtools.Controls;
名称空间ImageViewerItems
{
///<摘要>
///xaml的交互逻辑
///> < /总结
公共部分类MainWindow:窗口
{
公共主窗口()
{
InitializeComponent ();
}
静态类LEAD_VARS
{
公共常量字符串ImagesDir =@“C: \ LEADTOOLS22 \ Resources \图片”;
}
私人无效ImageViewer_Loaded (对象发送者,RoutedEventArgs
{
_imageList.Zoom (ControlSizeMode。拉伸,1.0,_imageList.DefaultZoomOrigin);
使用(RasterCodecs codecs =新RasterCodecs ())
{
字符串srcFileName = Path.Combine(LEAD_VARS.ImagesDir,@“ImageProcessingDemo \ NaturalFruits.jpg”);
RasterImage image = codecs.Load(srcFileName);
_imageList。Image =图像;
}
}
}
}
构建并运行程序以测试它。
放大镜。访问放大镜需要粘贴以下XAML代码。确保从文件中删除任何其他代码。
<窗口xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns: x = " http://schemas.microsoft.com/winfx/2006/xaml "
x: Class = " ImageViewerItems。主窗口”
x: Name = "窗口"
Title =“ImageViewerItems”
宽度= " 640 "
身高= " 480 "
xmlns: Leadtools_Controls_Wpf = " clr-namespace: Leadtools.Controls;装配= Leadtools.Controls.Wpf”>
<网格x: Name = " LayoutRoot ">
<Leadtools_Controls_Wpf:ImageViewer x:Name="_imageList" Margin="124,132,205,124" Loaded="ImageViewer_Loaded">
<Leadtools_Controls_Wpf: imageview。InteractiveModes>
<Leadtools_Controls_Wpf:ImageViewerMagnifyGlassInteractiveMode Shape="Rectangle" ScaleFactor="3" IsEnabled="True"/>
</ Leadtools_Controls_Wpf: imageview。InteractiveModes>
</ Leadtools_Controls_Wpf: imageview>
</网格>
</窗口>
构建并运行程序以测试它。
<窗口xmlns = " http://schemas.microsoft.com/winfx/2006/xaml/presentation "
xmlns: x = " http://schemas.microsoft.com/winfx/2006/xaml "
x: Class = " ImageViewerItems。主窗口”
x: Name = "窗口"
Title =“ImageViewerItems”
宽度= " 640 "
身高= " 480 "
xmlns: Leadtools_Controls_Wpf = " clr-namespace: Leadtools.Controls;装配= Leadtools.Controls.Wpf”>
<网格x: Name = " LayoutRoot ">
<Leadtools_Controls_Wpf:ImageViewer x:Name="_imageList" viewhorizontalalign ="Center" viewverticalalign ="Center" ItemSpacing="10,10" ItemSize="150,150" ItemBorderThickness="1" Loaded="ImageViewer_Loaded">
<Leadtools_Controls_Wpf: imageview。ViewLayout>
<= " 1 " / Leadtools_Controls_Wpf: ImageViewerVerticalViewLayout列>
</ Leadtools_Controls_Wpf: imageview。ViewLayout>
<Leadtools_Controls_Wpf: imageview。InteractiveModes>
<Leadtools_Controls_Wpf:ImageViewerMagnifyGlassInteractiveMode Shape="Rectangle" ScaleFactor="3" IsEnabled="True"/>
</ Leadtools_Controls_Wpf: imageview。InteractiveModes>
</ Leadtools_Controls_Wpf: imageview>
</网格>
</窗口>
使用先;
使用System.Windows;
使用Leadtools;
使用Leadtools.Codecs;
使用Leadtools.Controls;
名称空间ImageViewerItems
{
///<摘要>
///xaml的交互逻辑
///> < /总结
公共部分类MainWindow:窗口
{
公共主窗口()
{
InitializeComponent ();
}
LeadSize _imageSize = LeadSize。创建(130、130);
私人无效ImageViewer_Loaded (对象发送者,RoutedEventArgs
{
AddItem (Path.Combine (LEAD_VARS.ImagesDir@“ImageProcessingDemo \ NaturalFruits.jpg”));
AddItem (Path.Combine (LEAD_VARS.ImagesDir@“ImageProcessingDemo \ Ani.gif”));
AddItem (Path.Combine (LEAD_VARS.ImagesDir@“ImageProcessingDemo \ Image2.jpg”));
}
私人无效AddItem (字符串文件名)
{
使用(RasterCodecs codecs =新RasterCodecs ())
{
_imageList.BeginUpdate ();
RasterImage = codecs.Load(fileName);
LeadRect destRect = LeadRect。创建(0,0,_imageSize.)宽度,_imageSize.Height);
LeadRect imag勃起= ImageViewer。GetDestinationRectangle (
rasterImage。ImageWidth,
rasterImage。ImageHeight,
destRect,
ControlSizeMode。健康,
ControlAlignment。附近,
ControlAlignment.Near);
RasterImage缩略图= RasterImage。CreateThumbnail (
imageRect。宽度,
imageRect。高度,
32岁的
RasterViewPerspective。TopLeft,
RasterSizeFlags.Resample);
ImageViewerItem item =新ImageViewerItem ();
项。图片=缩略图;
_imageList.Items.Add(项);
_imageList.EndUpdate ();
}
}
静态类LEAD_VARS
{
公共常量字符串ImagesDir =@“C: \ LEADTOOLS22 \ Resources \图片”;
}
}
}
帮助收藏
光栅net|C API|c++类库|HTML5 JavaScript
文档net|C API|c++类库|HTML5 JavaScript
医疗net|C API|c++类库|HTML5 JavaScript
医疗网络查看器net
188宝金博怎么下载
支持的平台上
.NET、Java、Android和iOS/macOS程序集
C API/ c++类库
HTML5 JavaScript库
您的邮件已发送给技术支持!应该有人联系!如果你的事情很紧急,请回来聊天。
聊天时间:
周一至周五,美国东部时间上午8:30至下午6:00
感谢您的反馈!
请再次填写表格,开始新的聊天。
所有代理目前都离线。
聊天时间:
星期一至星期五
美国东部时间上午8:30 -下午6点
如需与我们联系,请填写此表格,我们将通过电子邮件与您联系。