RasterImage and WPF

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).

Image Display

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 it 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 Leadtools.RasterImage objects. So to display a LEADTOOLS image, simply call one of the image conversion methods described below to obtain a 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 magnifying glass.

Image Conversion

The LEADTOOLS RasterImage class supports more pixel and color formats than the WPF System.Windows.Media.ImageSource and its derived classes. LEADTOOLS toolkits allow you to convert a RasterImage object to or from a WPF System.Windows.Media.ImageSource object.

Conversion to and from WPF Images

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.

XAML Support

LEADTOOLS does not provide support for using a Leadtools.RasterImage object directly in a WPF XAML file through the Leadtools.Controls.ImageViewer class. In order to set the Leadtools.Controls.ImageViewer image, load the Leadtools.RasterImage object and pass it to the ImageViewer control inside your code behind file.

The following is supported in XAML:

Region Conversion

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.

See Also

Help Version 21.0.2021.11.1
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Imaging, Medical, and Document
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.