public static bool IsValidBitsPerPixel(int bitsPerPixel)
Public Shared Function IsValidBitsPerPixel( _ByVal bitsPerPixel As Integer _) As Boolean
public:static bool IsValidBitsPerPixel(int bitsPerPixel)
bitsPerPixel
The input bits per pixel value.
true if bitsPerPixel is compatible with GDI+, otherwise it is false.
For more information refer to RasterImage and GDI/GDI+.
using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;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 trueif (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-bitColorResolutionCommand 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 falseif (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:\LEADTOOLS21\Resources\Images";}
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.DrawingImports Leadtools.ImageProcessingImports Leadtools.ImageProcessing.ColorPublic 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 trueIf RasterImageConverter.IsValidBitsPerPixel(image.BitsPerPixel) ThenConsole.WriteLine(String.Format("{0} is a valid GDI+ bits/pixel", image.BitsPerPixel))ElseConsole.WriteLine(String.Format("{0} is not a valid GDI+ bits/pixel", image.BitsPerPixel))End If' change this image to grayscale 12-bitDim 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 falseIf RasterImageConverter.IsValidBitsPerPixel(image.BitsPerPixel) ThenConsole.WriteLine(String.Format("{0} is a valid GDI+ bits/pixel", image.BitsPerPixel))ElseConsole.WriteLine(String.Format("{0} is not a valid GDI+ bits/pixel", image.BitsPerPixel))End IfEnd Usingcodecs.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"End Class
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
