Changes a LEAD
RasterImage object to a Windows Device Dependent Bitmap (DDB).
Syntax
Visual Basic (Declaration) | |
---|
Public Overloads Function ChangeToHBitmap() As IntPtr |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As RasterImage
Dim value As IntPtr
value = instance.ChangeToHBitmap()
|
C# | |
---|
public IntPtr ChangeToHBitmap() |
C++/CLI | |
---|
public:
IntPtr ChangeToHBitmap(); |
Return Value
A handle to the device dependent bitmap (DDB) this method creates.
Example
This example loads a RasterImage, changes it to a DDB and
then changes it back to RasterImage.
Visual Basic | Copy Code |
---|
Public Sub ChangeToHBitmapExample()
RasterCodecs.Startup()
Dim codecs As New RasterCodecs()
Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp", 24, CodecsLoadByteOrder.BgrOrGray, 1, 1)
Dim hbitmap As IntPtr = image.ChangeToHBitmap()
image.Dispose()
image = RasterImage.ChangeFromHBitmap(hbitmap, IntPtr.Zero)
codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "Image1_ChangeToHBitmap.bmp", RasterImageFormat.Bmp, 24)
image.Dispose()
DeleteObject(hbitmap)
codecs.Dispose()
RasterCodecs.Shutdown()
End Sub |
C# | Copy Code |
---|
public void ChangeToHBitmapExample() { RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); // Load an image RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp", 24, CodecsLoadByteOrder.BgrOrGray, 1, 1); // Change to DDB IntPtr hbitmap = image.ChangeToHBitmap(); // Dispose the image since it is unusable now image.Dispose(); // Change the DDB to a new LEAD RasterImage image = RasterImage.ChangeFromHBitmap(hbitmap, IntPtr.Zero); // Save this image back to disk codecs.Save(image, LeadtoolsExamples.Common.ImagesPath.Path + "Image1_ChangeToHBitmap.bmp", RasterImageFormat.Bmp, 24); image.Dispose(); // Clean up DeleteObject(hbitmap); codecs.Dispose(); RasterCodecs.Shutdown(); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family
See Also