The LEADTOOLS RasterImage class provides platform independent representation of an image. It serves as a working area for image manipulation and conversion. LEADTOOLS functions use this class for accessing the image in memory and for maintaining the characteristics of the image. This topic discusses how to use the LEADTOOLS RasterImage class with the Windows Presentation Foundation (WPF) platform (System.Windows.Media).
In the Microsoft WPF platforms, you do not paint an image directly on the screen. Instead, you put your graphics content into an System.Windows.Media.ImageSource object or one of its derived classes and then display this object by either putting inside an System.Windows.Controls.Image tag in the XAML file or through the System.Windows.Media.DrawingContext.DrawImage(System.Windows.Media.ImageSource,System.Windows.Rect) method which also takes System.Windows.Media.ImageSource as the source image parameter.
LEADTOOLS images are typically stored in a Leadtools.RasterImage object. So to display a LEADTOOLS image, simply call one of the image conversion methods described below to obtain an System.Windows.Media.ImageSource from the Leadtools.RasterImage.
Also, LEADTOOLS comes with feature rich controls for writing WPF applications such as Leadtools.Controls.ImageViewer. Using this control, you can display Leadtools.RasterImage in your application with many effects such as scrolling, panning, zooming and magnify glass.
The LEADTOOLS RasterImage class supports more pixel and color formats than the WPF System.Windows.Media.ImageSource and its derived classes. LEADTOOLS allow you to convert a RasterImage object to or from a WPF System.Windows.Media.ImageSource object.
Use the RasterImageConverter.ConvertToSource method to convert a RasterImage to a WPF System.Windows.Media.ImageSource object. Use RasterImageConverter.ConvertFromSource to convert a System.Windows.Media.ImageSource object to a RasterImage.
LEADTOOLS does not provide support for using a Leadtools.RasterImage object directly in the WPF XAML file through the Leadtools.Controls.ImageViewer class, in order to set the Leadtools.Controls.ImageViewer image you need to load Leadtools.RasterImage object and pass it to the ImageViewer control inside your code behind file.
The following is supported in XAML:
A URL to an image file with extra options. For example:
A resource file in the project. Add any image file to your project and set its build events to Resource, then reference it in the XAML as follows:
The LEADTOOLS RasterImage has an optional region area that can be used to restrict manipulating the image data to a certain area. You can use the RasterImage.GetRegion to obtain the current region in a RasterImage as a RasterRegion object. Also, the RasterImage.SetRegion method can be used to set or combine a new region in a RasterImage.
Use the RasterRegionConverter.ConvertToGeometry to convert a RasterRegion object to a WPF System.Windows.Media.Geometry object. The RasterRegionConverter.ConvertFromGeometry can be used to convert a WPF System.Windows.Media.Geometry to a RasterRegion. For information on using RasterImage with GDI and GDI+ refer to RasterImage and Gdi/Gdi+
Medical Web Viewer .NET