public static RasterImage ConvertFromSource(ImageSource image,ConvertFromSourceOptions options)
image
The System.Windows.Media.ImageSource object containing the image data to convert.
options
Options to control the conversion operation. Currently there are no extra options and the value of this parameter must be set to ConvertFromSourceOptions.None
A Leadtools.RasterImage object representing the converted image.
LEADTOOLS and WPF support different pixel formats. These pixel formats may not be identical in some cases. The conversion process takes care of converting scanlines to a suitable format that best matches the source data. The following table shows the result bits/pixel byte order achieved when passing images with different pixel format values:
This example will use get the WPF System.Windows.Media.ImageSource in an System.Windows.Controls.Image control, use LEADTOOLS to invert it and then set it back into the control.
using Leadtools;using Leadtools.Codecs;using Leadtools.ImageProcessing;using Leadtools.Windows.Media;private void ConvertFromSourceExample(System.Windows.Controls.Image imageControl){// Get the WPF/Silverlight source image in the Image controlImageSource source = imageControl.Source;// Convert it to a LEADTOOLS RasterImageusing (RasterImage rasterImage = RasterImageConverter.ConvertFromSource(source, ConvertFromSourceOptions.None)){// Now, use LEADTOOLS to Invert the imageLeadtools.ImageProcessing.Color.InvertCommand cmd = new Leadtools.ImageProcessing.Color.InvertCommand();cmd.Run(rasterImage);// Convert the back to WPF/Silverlightsource = RasterImageConverter.ConvertToSource(rasterImage, ConvertToSourceOptions.None);// Set it back into the Image controlimageControl.Source = source;}}