←Select platform

FromDib(IntPtr) Method

Summary
Creates a new image from the specified Windows Device Independent Bitmap (DIB) stored in an unmanaged pointer.
Syntax
C#
Objective-C
C++/CLI
Python
public static RasterImage FromDib(  
   IntPtr hdib 
) 
+ (nullable LTRasterImage *)fromDib:(LTHandle *)dib error:(NSError **)error 
public: 
static RasterImage^ FromDib(  
   IntPtr hdib 
)  
def FromDib(self,hdib): 

Parameters

hdib
Handle to the Windows DIB.

Return Value

The newly created RasterImage object.

Remarks

When this method is completed, there are two copies of the image in memory: the original DIB and the RasterImage it creates. Freeing one will not affect the other.

This method supports the standard DIB formats (BI_RGB and BI_BITFIELDS) as well as some FOURCC (Four Character Code) formats that some capture cards output.

These are the FOURCC that LEADTOOLS supports at the moment:

YVU9 (YUV9), I420 (YUV12), YUV2 , YV12 , IF09 , IYUV , UYVY , cyuv, YUY2, YVYU, Y41P, Y211, Y41T, Y42T.

This method does not support signed images.

For more information on DDBs and DIBs, refer to Using DIBs, DDBs, and the Clipboard.

Example
C#
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 Leadtools.Svg; 
 
 
public void ToDibExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   IntPtr dib; 
 
   using (RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"))) 
   { 
      dib = image.ToDib(RasterConvertToDibType.BitmapInfoHeader); 
   } 
 
   using (RasterImage image = RasterImage.FromDib(dib)) 
   { 
      codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_FromDib.bmp"), RasterImageFormat.Bmp, 0); 
   } 
 
   Marshal.FreeHGlobal(dib); 
 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 23.0.2024.5.22
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.