LEADTOOLS GDI/GDI+ (Leadtools.Drawing assembly)
LEAD Technologies, Inc

IsValidBitsPerPixel Method

Example 





The input bits per pixel value.
Determines whether the specified bits per pixel value supported by LEADTOOLS is compatible with GDI+.
Syntax
public static bool IsValidBitsPerPixel( 
   int bitsPerPixel
)
'Declaration
 
Public Shared Function IsValidBitsPerPixel( _
   ByVal bitsPerPixel As Integer _
) As Boolean
'Usage
 
Dim bitsPerPixel As Integer
Dim value As Boolean
 
value = RasterImageConverter.IsValidBitsPerPixel(bitsPerPixel)
public static bool IsValidBitsPerPixel( 
   int bitsPerPixel
)
 function Leadtools.Drawing.RasterImageConverter.IsValidBitsPerPixel( 
   bitsPerPixel 
)
public:
static bool IsValidBitsPerPixel( 
   int bitsPerPixel
) 

Parameters

bitsPerPixel
The input bits per pixel value.

Return Value

true if bitsPerPixel is compatible with GDI+, otherwise it is false.
Remarks

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

Example
 
Public Sub IsValidBitsPerPixelExample()
      Dim codecs As New RasterCodecs()
      Using image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"))
         ' check if this image has a valid gdi plus bits/pixel.  It should say true
         If RasterImageConverter.IsValidBitsPerPixel(image.BitsPerPixel) Then
            Console.WriteLine(String.Format("{0} is a valid GDI+ bits/pixel", image.BitsPerPixel))
         Else
            Console.WriteLine(String.Format("{0} is not a valid GDI+ bits/pixel", image.BitsPerPixel))
         End If

         ' change this image to grayscale 12-bit
         Dim cmd As New ColorResolutionCommand( _
            ColorResolutionCommandMode.InPlace, _
            12, _
            RasterByteOrder.Gray, _
            RasterDitheringMethod.None, _
            ColorResolutionCommandPaletteFlags.Optimized, _
            Nothing)

         cmd.Run(image)

         ' check if this image has a valid gdi plus bits/pixel.  It should say false
         If RasterImageConverter.IsValidBitsPerPixel(image.BitsPerPixel) Then
            Console.WriteLine(String.Format("{0} is a valid GDI+ bits/pixel", image.BitsPerPixel))
         Else
            Console.WriteLine(String.Format("{0} is not a valid GDI+ bits/pixel", image.BitsPerPixel))
         End If
      End Using

      codecs.Dispose()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void IsValidBitsPerPixelExample()
   {
      RasterCodecs codecs = new RasterCodecs();
      using(RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")))
      {
         // check if this image has a valid gdi plus bits/pixel.  It should say true
         if(RasterImageConverter.IsValidBitsPerPixel(image.BitsPerPixel))
         {
            Console.WriteLine(string.Format("{0} is a valid GDI+ bits/pixel", image.BitsPerPixel));
         }
         else
         {
            Console.WriteLine(string.Format("{0} is not a valid GDI+ bits/pixel", image.BitsPerPixel));
         }

         // change this image to grayscale 12-bit
         ColorResolutionCommand cmd = new ColorResolutionCommand(
            ColorResolutionCommandMode.InPlace,
            12,
            RasterByteOrder.Gray,
            RasterDitheringMethod.None,
            ColorResolutionCommandPaletteFlags.Optimized,
            null);

         cmd.Run(image);

         // check if this image has a valid gdi plus bits/pixel.  It should say false
         if(RasterImageConverter.IsValidBitsPerPixel(image.BitsPerPixel))
         {
            Console.WriteLine(string.Format("{0} is a valid GDI+ bits/pixel", image.BitsPerPixel));
         }
         else
         {
            Console.WriteLine(string.Format("{0} is not a valid GDI+ bits/pixel", image.BitsPerPixel));
         }
      }

      codecs.Dispose();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterImageConverter Class
RasterImageConverter Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.