Gets an unmanaged pointer containing a Windows device independent bitmap (DIB) version of this image.
public IntPtr ToDib(
Leadtools.RasterConvertToDibType type
)
Public Function ToDib( _
ByVal type As Leadtools.RasterConvertToDibType _
) As IntPtr
public IntPtr ToDib(
Leadtools.RasterConvertToDibType type
)
- (nullable LTHandle *)toDib:(LTRasterConvertToDibType)type
function Leadtools.RasterImage.ToDib(
type
)
public:
IntPtr ToDib(
Leadtools.RasterConvertToDibType type
)
type
Type of DIB to create.
A handle to the Windows DIB.
When this method is completed, there are two copies of the image in memory: the DIB and the original RasterImage. Freeing one will not affect the other.
This methods allocates a DIB bitmap and copies the RasterImage to the DIB.
NOTE: This method returns the data in an unmanaged buffer. The caller is responsible for freeing the DIB's IntPtr when it is no longer needed. You can use Marshal.FreeHGlobal.
A DIB consists of one of the following:
followed by a color table and then the bitmap data. The resulting DIB type is determined by the value of the type parameter.
The orientation of the image and color order will depend on how the image was loaded into the RasterImage.
When you no longer need the DIB, you can free it using the Windows GlobalFree function or FreeHGlobal.
For more information on DDBs and DIBs, refer to Introduction: DIBs, DDBs, and the Clipboard.
This function does not support signed images.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
using Leadtools.Drawing;
using Leadtools.Controls;
using LeadtoolsExamples.Common;
using Leadtools.Svg;
public void ToDibExample()
{
RasterCodecs codecs = new RasterCodecs();
IntPtr dib;
using (RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "Image1.cmp")))
{
dib = image.ToDib(RasterConvertToDibType.BitmapInfoHeader);
}
using (RasterImage image = RasterImage.FromDib(dib))
{
codecs.Save(image, Path.Combine(ImagesPath.Path, "Image1_FromDib.bmp"), RasterImageFormat.Bmp, 0);
}
Marshal.FreeHGlobal(dib);
codecs.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Controls
Imports Leadtools.Dicom
Imports Leadtools.Drawing
Imports Leadtools.Svg
Public Sub ToDibExample()
Dim codecs As RasterCodecs = New RasterCodecs()
Dim dib As IntPtr
Using image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"))
dib = image.ToDib(RasterConvertToDibType.BitmapInfoHeader)
End Using
Using image As RasterImage = RasterImage.FromDib(dib)
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_FromDib.bmp"), RasterImageFormat.Bmp, 0)
End Using
Marshal.FreeHGlobal(dib)
codecs.Dispose()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
RasterImageConverter.FromHBitmap
RasterImageConverter.ToHBitmap
Products |
Support |
Feedback: ToDib Method - Leadtools |
Introduction |
Help Version 19.0.2017.6.19
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.