Tests a Leadtools.RasterImage to see if it is compatible with the WPF System.Windows.Media.ImageSource.
public static ImageIncompatibleReason TestCompatible(
RasterImage image,
ConvertToSourceOptions options
)
Public Shared Function TestCompatible( _
ByVal image As RasterImage, _
ByVal options As ConvertToSourceOptions _
) As ImageIncompatibleReason
public:
static ImageIncompatibleReason TestCompatible(
RasterImage^ image,
ConvertToSourceOptions options
)
image
The source image.
options
The options to use when testing.
Value indicating the compatibility.
For more information on WPF compatibility, refer to ConvertToSource.
For more information refer to RasterImage and WPF.
This example will loop through all the image files shipped with LEADTOOLS and check if they are compatible with WPF.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.Windows.Media;
public void TestCompatibleExample()
{
string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
using (RasterCodecs codecs = new RasterCodecs())
{
// Load the image as 32-bit at BGR color order
using (RasterImage image = codecs.Load(srcFileName, 32, CodecsLoadByteOrder.Bgr, 1, 1))
{
// This should report that the image is compatible
ImageIncompatibleReason reason = RasterImageConverter.TestCompatible(image, ConvertToSourceOptions.None);
Console.WriteLine("Bits/Pixel: {0}, Order: {1}, ViewPerspective: {2}, Test compatible: {3}", image.BitsPerPixel, image.Order, image.ViewPerspective, reason);
}
// Load the image as 12-bit grayscale image, this is incomaptible with WPF/Silverlight
using (RasterImage image = codecs.Load(srcFileName, 12, CodecsLoadByteOrder.Gray, 1, 1))
{
// This should report that the image is compatible
ImageIncompatibleReason reason = RasterImageConverter.TestCompatible(image, ConvertToSourceOptions.None);
Console.WriteLine("Bits/Pixel: {0}, Order: {1}, ViewPerspective: {2}, Test compatible: {3}", image.BitsPerPixel, image.Order, image.ViewPerspective, reason);
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Windows.Media
Public Sub TestCompatibleExample()
Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
Using codecs As New RasterCodecs()
' Load the image as 32-bit at BGR color order
Using image As RasterImage = codecs.Load(srcFileName, 32, CodecsLoadByteOrder.Bgr, 1, 1)
' This should report that the image is compatible
Dim reason As ImageIncompatibleReason = RasterImageConverter.TestCompatible(image, ConvertToSourceOptions.None)
Console.WriteLine("Bits/Pixel: {0}, Order: {1}, ViewPerspective: {2}, Test compatible: {3}", image.BitsPerPixel, image.Order, image.ViewPerspective, reason)
End Using
' Load the image as 12-bit grayscale image, this is incomaptible with WPF/Silverlight
Using image As RasterImage = codecs.Load(srcFileName, 12, CodecsLoadByteOrder.Gray, 1, 1)
' This should report that the image is compatible
Dim reason As ImageIncompatibleReason = RasterImageConverter.TestCompatible(image, ConvertToSourceOptions.None)
Console.WriteLine("Bits/Pixel: {0}, Order: {1}, ViewPerspective: {2}, Test compatible: {3}", image.BitsPerPixel, image.Order, image.ViewPerspective, reason)
End Using
End Using
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
c#[Silverlight C# Example]
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.Windows.Media;
public void TestCompatibleExample()
{
string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp";
RasterCodecs codecs = new RasterCodecs();
// Load the image as 32-bit at BGR color order
using (RasterImage image = codecs.Load(srcFileName, 32, CodecsLoadByteOrder.Bgr, 1, 1))
{
// This should report that the image is compatible
ImageIncompatibleReason reason = RasterImageConverter.TestCompatible(image, ConvertToSourceOptions.None);
Console.WriteLine("Bits/Pixel: {0}, Order: {1}, ViewPerspective: {2}, Test compatible: {3}", image.BitsPerPixel, image.Order, image.ViewPerspective, reason);
}
// Load the image as 12-bit grayscale image, this is incomaptible with WPF/Silverlight
using (RasterImage image = codecs.Load(srcFileName, 12, CodecsLoadByteOrder.Gray, 1, 1))
{
// This should report that the image is compatible
ImageIncompatibleReason reason = RasterImageConverter.TestCompatible(image, ConvertToSourceOptions.None);
Console.WriteLine("Bits/Pixel: {0}, Order: {1}, ViewPerspective: {2}, Test compatible: {3}", image.BitsPerPixel, image.Order, image.ViewPerspective, reason);
}
}
vb[Silverlight VB Example]
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.Windows.Media
Imports Leadtools.ImageProcessing.Color
Public Sub TestCompatibleExample()
Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path & "Image1.cmp"
Dim codecs As RasterCodecs = New RasterCodecs()
' Load the image as 32-bit at BGR color order
Using image As RasterImage = codecs.Load(srcFileName, 32, CodecsLoadByteOrder.Bgr, 1, 1)
' This should report that the image is compatible
Dim reason As ImageIncompatibleReason = RasterImageConverter.TestCompatible(image, ConvertToSourceOptions.None)
Console.WriteLine("Bits/Pixel: {0}, Order: {1}, ViewPerspective: {2}, Test compatible: {3}", image.BitsPerPixel, image.Order,
image.ViewPerspective, reason)
End Using
' Load the image as 12-bit grayscale image, this is incomaptible with WPF/Silverlight
Using image As RasterImage = codecs.Load(srcFileName, 12, CodecsLoadByteOrder.Gray, 1, 1)
' This should report that the image is compatible
Dim reason As ImageIncompatibleReason = RasterImageConverter.TestCompatible(image, ConvertToSourceOptions.None)
Console.WriteLine("Bits/Pixel: {0}, Order: {1}, ViewPerspective: {2}, Test compatible: {3}", image.BitsPerPixel, image.Order,
image.ViewPerspective, reason)
End Using
End Sub
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.