public static IntPtr ChangeToHBitmap(RasterImage image,IntPtr hdc)
image
The source image.
hdc
Handle to the device responsible for the conversion. The mapping mode of the device context must be MM_TEXT.
A handle to the device dependent bitmap (DDB) this method creates.
This method results in only one copy of the image, and it invalidates this Leadtools.RasterImage object. You must call RasterImage.Dispose after calling this method.
For more information on DDBs, DIBs, GDI and GDI+ refer to Using DIBs, DDBs, and the Clipboard and RasterImage and GDI/GDI+.
using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;public void ChangeToHBitmapExample(){RasterCodecs codecs = new RasterCodecs();IntPtr hbitmap;// Load an imageusing (RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 24, CodecsLoadByteOrder.BgrOrGray, 1, 1)){// Change to DDBhbitmap = RasterImageConverter.ChangeToHBitmap(image);// Dispose the image since it is unusable now}// Change the DDB to a new LEAD RasterImageusing (RasterImage image = RasterImageConverter.ChangeFromHBitmap(hbitmap, IntPtr.Zero)){// Save this image back to diskcodecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_ChangeToHBitmap.bmp"), RasterImageFormat.Bmp, 24);}DeleteObject(hbitmap);// Clean upcodecs.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}