public static IntPtr ChangeToHBitmap(
RasterImage image
)
Public Overloads Shared Function ChangeToHBitmap( _
ByVal image As RasterImage _
) As IntPtr
public:
static IntPtr ChangeToHBitmap(
RasterImage^ image
)
image
The source image.
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 and DIBs, refer to Using DIBs, DDBs, and the Clipboard.
For more information refer to RasterImage and GDI/GDI+.
For an example, refer to ChangeToHBitmap(RasterImage). This example loads a Leadtools.RasterImage, changes it to a DDB and then changes it back to Leadtools.RasterImage.
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 image
using (RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 24, CodecsLoadByteOrder.BgrOrGray, 1, 1))
{
// Change to DDB
hbitmap = RasterImageConverter.ChangeToHBitmap(image);
// Dispose the image since it is unusable now
}
// Change the DDB to a new LEAD RasterImage
using (RasterImage image = RasterImageConverter.ChangeFromHBitmap(hbitmap, IntPtr.Zero))
{
// Save this image back to disk
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_ChangeToHBitmap.bmp"), RasterImageFormat.Bmp, 24);
}
DeleteObject(hbitmap);
// Clean up
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Drawing
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Public Sub ChangeToHBitmapExample()
Dim codecs As New RasterCodecs()
Dim hbitmap As IntPtr
' Load an image
Using image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 24, CodecsLoadByteOrder.BgrOrGray, 1, 1)
' Change to DDB
hbitmap = RasterImageConverter.ChangeToHBitmap(image)
' Dispose the image since it is unusable now
End Using
' Change the DDB to a new LEAD RasterImage
Using image As RasterImage = RasterImageConverter.ChangeFromHBitmap(hbitmap, IntPtr.Zero)
' Save this image back to disk
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_ChangeToHBitmap.bmp"), RasterImageFormat.Bmp, 24)
End Using
DeleteObject(hbitmap)
' Clean up
codecs.Dispose()
End Sub
Public NotInheritable Class LEAD_VARS
Public 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