L_ChangeToDIB

#include "l_bitmap.h"

L_LTKRN_API L_HDIB L_ChangeToDIB(pBitmap, uType)

pBITMAPHANDLE pBitmap;

pointer to the bitmap

L_UINT uType;

type of DIB

Changes a LEAD bitmap handle to a Windows Device Independent Bitmap (DIB).

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the bitmap to change.

uType

Type of DIB to create. Possible values are:

 

Value

Meaning

 

DIB_BITMAPINFOHEADER

[0] DIB that uses a BITMAPINFOHEADER

 

DIB_BITMAPV4HEADER

[1] DIB that uses a BITMAPV4HEADER. (Introduced in Windows 95 and Windows NT 4.0)

 

DIB_BITMAPV5HEADER

[2] DIB that uses a BITMAPV5HEADER (Introduced in Windows 2000 and Windows 98)

Returns

>0

Global memory handle to DIB.

0

An error occurred.

Comments

This function results in only one copy of the bitmap, and it invalidates the LEAD bitmap handle. The DIB will have a BITMAPINFOHEADER, a BITMAPV4HEADER, or a BITMAPV5HEADER depending on the uType argument.

This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

The orientation of the image and color order will depend on how the image was loaded into the LEAD bitmap.

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 uType flag.

The orientation of the image and color order will depend on how the image was loaded into the LEAD bitmap.

If you want to load another image using the same bitmap handle, you must initialize the bitmap handle again.

When you no longer need the DIB, you can free it using the Windows GlobalFree function.

Regions are not supported on the Windows CE platform.

Required DLLs and Libraries

LTKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64, Linux.

See Also

Functions:

L_ConvertFromDDB, L_ConvertFromDIB, L_ConvertToDDB, L_ConvertToDIB, L_ChangeFromDDB, L_ChangeFromDIB, L_ChangeToDDB

Topics:

Raster Image Functions: Creation, Deletion, and Copying

 

Using DIBs, DDBs, and the Clipboard

Example

This example takes a LEAD bitmap, changes it to a V5 DIB and writes out the DIB as a bitmap file

#include <fcntl.h> 
 
L_INT MySaveFile(HGLOBAL hDIB, L_TCHAR * pszFileName) 
{ 
   DWORD             dwSize; 
   HANDLE            fp; 
   L_UCHAR*          pDIB; 
   BITMAPFILEHEADER  bfh; 
   PBITMAPINFOHEADER pbih; 
   L_SIZE_T          zDIBsize; 
 
   zDIBsize = GlobalSize(hDIB); 
 
   bfh.bfType        = 0x4d42; //"BM"; 
   bfh.bfSize        = (DWORD) (sizeof(BITMAPFILEHEADER) + zDIBsize); 
   bfh.bfReserved1   = 0; 
   bfh.bfReserved2   = 0; 
 
   pDIB = (L_UCHAR *)GlobalLock(hDIB); 
   pbih = (PBITMAPINFOHEADER)pDIB; 
 
   // Compute the offset to the array of color indices.  
   bfh.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +  
                    pbih->biSize + pbih->biClrUsed  * sizeof (RGBQUAD);  
 
   fp = CreateFile(pszFileName, GENERIC_WRITE | GENERIC_READ , 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); 
 
   if (fp == 0) 
      return FALSE; 
 
   WriteFile(fp, &bfh, sizeof(BITMAPFILEHEADER), &dwSize, NULL); 
   WriteFile(fp, pDIB, (L_UINT) zDIBsize, &dwSize, NULL); 
   CloseHandle(fp); 
 
   GlobalUnlock(hDIB); 
   return TRUE; 
} 
 
L_INT ChangeToDIBExample(pBITMAPHANDLE      pBitmap,L_TCHAR*           pszFileName) 
{ 
 
   HGLOBAL hDIB; 
   hDIB = L_ChangeToDIB(pBitmap, DIB_BITMAPINFOHEADER); 
   if(hDIB == 0 ) 
      return 0; 
 
   //At this point, the original pBitmap is now invalid 
   MySaveFile(hDIB, pszFileName); 
   GlobalFree(hDIB); 
   return SUCCESS; 
} 

Help Version 20.0.2018.1.19
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help