RasterImage and WPF/Silverlight

Show in webframe

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 discus how to use the LEADTOOLS RasterImage class with the Windows Presentation Foundation (WPF) and Silverlight platforms (System.Windows.Media).

Image Display

In the Microsoft WPF and Silverlight 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/Silverlight applications such as the Leadtools.Windows.Controls.ImageBox, Leadtools.Windows.Controls.ImageViewer, Leadtools.Windows.Controls.RasterImageBox and Leadtools.Windows.Controls.RasterImageViewer. These are composite controls that include an System.Windows.Controls.Image tag inside. Using these controls, you can display an System.Windows.Media.ImageSource or Leadtools.RasterImage in your application with many effects such as automatic handling of Leadtools.RasterImage changes and conversion to System.Windows.Media.ImageSource, scrolling, panning, zooming and magnify glass.

Image Conversion

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

Conversion to and from WPF/Silverlight Images

Use the RasterImageConverter.ConvertToSource method to convert a RasterImage to a WPF/Silverlight System.Windows.Media.ImageSource object. Use RasterImageConverter.ConvertFromSource to convert a System.Windows.Media.ImageSource object to a RasterImage.

XAML Support

LEADTOOLS provides support for using a Leadtools.RasterImage object directly in the WPF or Silverlight XAML file through the the Leadtools.Windows.Controls.RasterImageViewer class. By using the Leadtools.Codecs.RasterImageTypeConverter internally, LEADTOOLS will parse the XAML code and loads the provided image into the viewer.

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/Silverlight System.Windows.Media.Geometry object. The RasterRegionConverter.ConvertFromGeometry can be used to convert a WPF/Silverlight System.Windows.Media.Geometry to a RasterRegion.

For information on using RasterImage with GDI and GDI+ refer to RasterImage and Gdi/Gdi+

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.