Leadtools.Windows.Media Namespace > RasterImageConverter Class : ConvertFromSource Method |
public static RasterImage ConvertFromSource( ImageSource image, ConvertFromSourceOptions options )
'Declaration Public Shared Function ConvertFromSource( _ ByVal image As ImageSource, _ ByVal options As ConvertFromSourceOptions _ ) As RasterImage
'Usage Dim image As ImageSource Dim options As ConvertFromSourceOptions Dim value As RasterImage value = RasterImageConverter.ConvertFromSource(image, options)
public static RasterImage ConvertFromSource( ImageSource image, ConvertFromSourceOptions options )
public: static RasterImage^ ConvertFromSource( ImageSource^ image, ConvertFromSourceOptions options )
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:
Microsoft Silverlight currently offers support for 32-bits/pixels only. So the result from this method will always be a Leadtools.RasterImage object with RasterImage.BitsPerPixel equals to 32.
Use the ConvertToSource method to convert LEADTOOLS Leadtools.RasterImage to a WPF/Silverlight System.Windows.Media.ImageSource object.
The conversion works by copying the image data over to the new destination. Currently, there is no support for sharing memory between a Leadtools.RasterImage and an System.Windows.Media.ImageSource.
For more information refer to RasterImage and WPF/Silverlight.
Private Sub ConvertFromSourceExample(ByVal imageControl As System.Windows.Controls.Image) ' Get the WPF/Silverlight source image in the Image control Dim source As ImageSource = imageControl.Source ' Convert it to a LEADTOOLS RasterImage Using rasterImage As RasterImage = RasterImageConverter.ConvertFromSource(source, ConvertFromSourceOptions.None) ' Now, use LEADTOOLS to Invert the image Dim cmd As New InvertCommand() cmd.Run(rasterImage) ' Convert the back to WPF/Silverlight source = RasterImageConverter.ConvertToSource(rasterImage, ConvertToSourceOptions.None) ' Set it back into the Image control imageControl.Source = source End Using End Sub
private void ConvertFromSourceExample(System.Windows.Controls.Image imageControl) { // Get the WPF/Silverlight source image in the Image control ImageSource source = imageControl.Source; // Convert it to a LEADTOOLS RasterImage using(RasterImage rasterImage = RasterImageConverter.ConvertFromSource(source, ConvertFromSourceOptions.None)) { // Now, use LEADTOOLS to Invert the image Leadtools.ImageProcessing.Color.InvertCommand cmd = new Leadtools.ImageProcessing.Color.InvertCommand(); cmd.Run(rasterImage); // Convert the back to WPF/Silverlight source = RasterImageConverter.ConvertToSource(rasterImage, ConvertToSourceOptions.None); // Set it back into the Image control imageControl.Source = source; } }
private void ConvertFromSourceExample(System.Windows.Controls.Image imageControl) { // Get the WPF/Silverlight source image in the Image control ImageSource source = imageControl.Source; // Convert it to a LEADTOOLS RasterImage using(RasterImage rasterImage = RasterImageConverter.ConvertFromSource(source, ConvertFromSourceOptions.None)) { // Now, use LEADTOOLS to Invert the image Leadtools.ImageProcessing.Color.InvertCommand cmd = new Leadtools.ImageProcessing.Color.InvertCommand(); cmd.Run(rasterImage); // Convert the back to WPF/Silverlight source = RasterImageConverter.ConvertToSource(rasterImage, ConvertToSourceOptions.None); // Set it back into the Image control imageControl.Source = source; } }
Private Sub ConvertFromSourceExample(ByVal imageControl As System.Windows.Controls.Image) ' Get the WPF/Silverlight source image in the Image control Dim source As ImageSource = imageControl.Source ' Convert it to a LEADTOOLS RasterImage Using rasterImage As RasterImage = RasterImageConverter.ConvertFromSource(source, ConvertFromSourceOptions.None) ' Now, use LEADTOOLS to Invert the image Dim cmd As InvertCommand = New InvertCommand() cmd.Run(rasterImage) ' Convert the back to WPF/Silverlight source = RasterImageConverter.ConvertToSource(rasterImage, ConvertToSourceOptions.None) ' Set it back into the Image control imageControl.Source = source End Using End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2