ConvertFromSource Method
Syntax
Parameters
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
Return Value
A Leadtools.RasterImage object representing the converted image.
Example
This example will use get the WPF/Silverlight System.Windows.Media.ImageSource in an System.Windows.Controls.Image control, use LEADTOOLS to invert it and then set it back into the control.
C#
VB
Silverlight C#
Silverlight VB
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 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;
}
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media
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
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 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;
}
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.Windows.Media
Imports Leadtools.ImageProcessing.Color
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