Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
IsValidBitsPerPixelGdiPlus Method
See Also  Example
Leadtools Namespace > RasterImage Class : IsValidBitsPerPixelGdiPlus Method



bitsPerPixel
The input bits per pixel value.
Determines whether or not the specified bits per pixel value supported by LEAD is compatible with GDI+.

Syntax

Visual Basic (Declaration) 
Public Shared Function IsValidBitsPerPixelGdiPlus( _
   ByVal bitsPerPixel As Integer _
) As Boolean
Visual Basic (Usage)Copy Code
Dim bitsPerPixel As Integer
Dim value As Boolean
 
value = RasterImage.IsValidBitsPerPixelGdiPlus(bitsPerPixel)
C# 
public static bool IsValidBitsPerPixelGdiPlus( 
   int bitsPerPixel
)
C++/CLI 
public:
static bool IsValidBitsPerPixelGdiPlus( 
   int bitsPerPixel
) 

Parameters

bitsPerPixel
The input bits per pixel value.

Return Value

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

Example

Visual BasicCopy Code
Public Sub IsValidBitsPerPixelGdiPlusExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP")

   ' check if this image has a valid gdi plus bits/pixel. It should say true
   If RasterImage.IsValidBitsPerPixelGdiPlus(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 ColorResolutionCommand = 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 RasterImage.IsValidBitsPerPixelGdiPlus(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

   image.Dispose()
   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void IsValidBitsPerPixelGdiPlusExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "IMAGE1.CMP"); 
 
   // check if this image has a valid gdi plus bits/pixel.  It should say true 
   if(RasterImage.IsValidBitsPerPixelGdiPlus(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(RasterImage.IsValidBitsPerPixelGdiPlus(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)); 
 
   image.Dispose(); 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family

See Also