←Select platform

ToDibArray Method

Summary

Gets a managed buffer containing a Windows device independent bitmap (DIB) version of this image.

Syntax

C#
VB
WinRT C#
C++
public byte[] ToDibArray( 
   RasterConvertToDibType type 
) 
Public Function ToDibArray( _ 
   ByVal type As Leadtools.RasterConvertToDibType _ 
) As Byte() 
public byte[] ToDibArray(  
   Leadtools.RasterConvertToDibType type 
) 
 function Leadtools.RasterImage.ToDibArray(  
   type  
) 
public: 
array<byte>^ ToDibArray(  
   Leadtools.RasterConvertToDibType type 
)  

Parameters

type
Type of DIB to create.

Return Value

An array of Byte that contains the handle to the Windows DIB.

Remarks

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.

A DIB consists of one of the following:

  • a BITMAPFILEHEADER
  • a BITMAPV4HEADER(introduced in Windows 95 and Windows NT 4.0)
  • or a BITMAPV5HEADER (introduced in Windows 2000 and Windows 98)

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.

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

This function does not support signed images.

Example

C#
VB
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 ToDibArrayExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   byte[] dibData; 
 
   using (RasterImage image = codecs.Load(Path.Combine(ImagesPath.Path, "Image1.cmp"))) 
   { 
      dibData = image.ToDibArray(RasterConvertToDibType.BitmapInfoHeader); 
   } 
 
   using (RasterImage image = RasterImage.FromDibArray(dibData, 0)) 
   { 
      codecs.Save(image, Path.Combine(ImagesPath.Path, "Image1_FromDibArray.bmp"), RasterImageFormat.Bmp, 0); 
   } 
 
   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 ToDibArrayExample() 
   Dim codecs As New RasterCodecs() 
 
   Dim dibData() As Byte 
 
   Using image As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")) 
      dibData = image.ToDibArray(RasterConvertToDibType.BitmapInfoHeader) 
   End Using 
 
   Using image As RasterImage = RasterImage.FromDibArray(dibData, 0) 
      codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Image1_FromDibArray.bmp"), RasterImageFormat.Bmp, 0) 
   End Using 
 
   codecs.Dispose() 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly