LEADTOOLS For .NET Class Library Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.28
The RasterPaintEngine Property and 16bpp Grayscale Images (Deprecated)

(Deprecated) The information in this topic is deprecated as of LEADTOOLS v16.5. The RasterPaintEngine.GdiPlus2 engine is obsolete now and its functionality has been merged with RasterPaintEngine.Gdi. The RasterPaintEngine.Gdi paint engine does not require the image to be GDI+ compatible and will work with any bits per pixel format supported by LEADTOOLS without changing the image data.

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 Leadtools.Drawing.RasterImagePainter.Paint(Leadtools.RasterImage,System.IntPtr,Leadtools.LeadRect,Leadtools.LeadRect,Leadtools.LeadRect,Leadtools.LeadRect,Leadtools.Drawing.RasterPaintProperties) method will call the Win32 API functions to paint the iamge.

Use the TestCompatible 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 Leadtools.Drawing.ImageIncompatibleReason.Order.

Use the ConvertToImage method to convert a RasterImage to a GDI+ image. Use the ChangeToImage method to obtain a GDI+ Image object that shares its data with a RasterImage object.