←Select platform

ImageIncompatibleReason Enumeration

Summary
Indicates the reason that the LEADTOOLS Leadtools.RasterImage object is not compatible with GDI+.
Syntax
C#
C++/CLI
Python
public enum ImageIncompatibleReason   
public enum class ImageIncompatibleReason   
class ImageIncompatibleReason(Enum): 
   Compatible = 0 
   BitsPerPixel = 1 
   Order = 2 
   Palette = 3 
   Data = 4 
   ViewPerspective = 5 
   Other = 6 
Members
ValueMemberDescription
0Compatible Image is compatible
1BitsPerPixel Unsupported Bits/Pixel
2Order Unsupported color byte order
3Palette Unsupported palette
4Data Unsupported raw data
5ViewPerspective Unsupported view perspective
6Other Unspecified reason
Remarks

For more information refer to RasterImage and GDI/GDI+.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
 
 
public void ConvertToImageExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
   string destFileName1 = Path.Combine(LEAD_VARS.ImagesDir, "GdiPlusImage.bmp"); 
   string destFileName2 = Path.Combine(LEAD_VARS.ImagesDir, "Image1_FromGdiPlusImage.bmp"); 
 
   // Load the image 
   using (RasterImage srcImage = codecs.Load(srcFileName)) 
   { 
      // Convert to GDI+ image 
      ImageIncompatibleReason reason = RasterImageConverter.TestCompatible(srcImage, true); 
      PixelFormat pf = RasterImageConverter.GetNearestPixelFormat(srcImage); 
      Console.WriteLine("TestCompatible: {0}", reason); 
      Console.WriteLine("GetNearestPixelFormat:{0}", pf); 
 
      if (reason != ImageIncompatibleReason.Compatible) 
      { 
         RasterImageConverter.MakeCompatible(srcImage, pf, true); 
      } 
 
      using (Image destImage1 = RasterImageConverter.ConvertToImage(srcImage, ConvertToImageOptions.None)) 
      { 
         // Save this image to disk 
         destImage1.Save(destFileName1, ImageFormat.Bmp); 
 
         // Convert the GDI+ image back to a RasterImage 
         using (RasterImage destImage2 = RasterImageConverter.ConvertFromImage(destImage1, ConvertFromImageOptions.None)) 
         { 
            // Save it to disk 
            codecs.Save(destImage2, destFileName2, RasterImageFormat.Bmp, 24); 
         } 
      } 
   } 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

See Also

Reference

Leadtools.Drawing Namespace

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

Leadtools.Drawing Assembly

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