When the GdiPlus paint engine is used (paintProperties.PaintEngine = RasterPaintEngine.GdiPlus), any 16-bit grayscale images that are loaded will be changed to 24- bits. This problem stems from the way the .NET Framework (GDI+) handles 16-bit grayscale images (even though a PixelFormat of Format16bppGrayScale is defined in .Net, it does not work). The LEADTOOLS RasterImageViewer uses straight GDI+ as the painting engine which does not accept 16-bit grayscale images. GDI+ converts such images to 24-bits. (In Version 14.5 special conversions were used to keep 16-bit images at 16-bits when GDI+ was used. To increase painting speed, the special conversions are no longer performed in Version 15.)
Set the RasterPaintEngine to Gdi in order to use the same methods used in LEADTOOLS Version 14.5 to keep 16-bit images at 16-bits when loaded in the viewer. When the RasterPaintEngine.GDI is used, the Paint method will call the Win32 API functions to paint the iamge.
Use the TestGdiPlusCompatible method to determine whether an image is a valid Gdi+ image. This method returns an enumeration value which indicates whether an image is compatible, and if it is not compatible, indicates the reason for the incompatibility. When used to test 16-bit grayscale images the method will return RasterGdiPlusIncompatibleReason.Order.
Use the ConvertToGdiPlusImage method to convert a RasterImage to a GDI+ image. Use the ChangeToGdiPlusImage method to obtain a GDI+ Image object that shares its data with a RasterImage object.