←Select platform

TestCompatible Method

Summary
Tests a Leadtools.RasterImage to see if it is compatible with the WPF System.Windows.Media.ImageSource.
Syntax
C#
VB
C++
  
Public Shared Function TestCompatible( _ 
   ByVal image As RasterImage, _ 
   ByVal options As ConvertToSourceOptions _ 
) As ImageIncompatibleReason 
public: 
static ImageIncompatibleReason TestCompatible(  
   RasterImage^ image, 
   ConvertToSourceOptions options 
)  

Parameters

image
The source image.

options
The options to use when testing.

Return Value

Value indicating the compatibility.

Remarks

For more information on WPF compatibility, refer to ConvertToSource.

For more information refer to RasterImage and WPF.

Example

This example will loop through all the image files shipped with LEADTOOLS and check if they are compatible with WPF.

C#
VB
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:\LEADTOOLS21\Resources\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:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.