LEADTOOLS WPF and Silverlight (Leadtools.Windows.Media assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.30
TestCompatible Method
See Also 
Leadtools.Windows.Media Namespace > RasterImageConverter Class : TestCompatible Method



image
The source image.
options
The options to use when testing.
image
The source image.
options
The options to use when testing.
Tests a Leadtools.RasterImage to see if it is compatible with the WPF/Silverlight System.Windows.Media.ImageSource. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Shared Function TestCompatible( _
   ByVal image As RasterImage, _
   ByVal options As ConvertToSourceOptions _
) As ImageIncompatibleReason
Visual Basic (Usage)Copy Code
Dim image As RasterImage
Dim options As ConvertToSourceOptions
Dim value As ImageIncompatibleReason
 
value = RasterImageConverter.TestCompatible(image, options)
C# 
public static ImageIncompatibleReason TestCompatible( 
   RasterImage image,
   ConvertToSourceOptions options
)
C++/CLI 
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.

Example

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

Visual BasicCopy Code
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#Copy Code
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";
}
SilverlightCSharpCopy Code
[TestMethod]
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);
   }
}
SilverlightVBCopy Code
<TestMethod> _
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

Remarks

For more information on WPF and Silverlight compatibility, refer to ConvertToSource.

For more information refer to RasterImage and WPF/Silverlight.

Requirements

Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also