L_ChangeToDIB
#include "l_bitmap.h"
HGLOBAL EXT_FUNCTION 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). 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.
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
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:
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 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.
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.
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
Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.
See Also
Functions: |
L_ConvertFromDDB, L_ConvertFromDIB, L_ConvertToDDB, L_ConvertToDIB, L_ChangeFromDDB, L_ChangeFromDIB, L_ChangeToDDB |
Topics: |
|
|
Example
//This example takes a LEAD bitmap, changes it to a V5 DIB and writes
//out the DIB as a bitmap file
#include <io.h>
#include <fcntl.h>
int MySaveFile(HGLOBAL hDIB, L_TCHAR L_FAR* pszFileName)
{
int fp, nSize;
unsigned char *pDIB;
BITMAPFILEHEADER bfh;
PBITMAPINFOHEADER pbih;
int nDIBsize;
nDIBsize = GlobalSize(hDIB);
bfh.bfType = 0x4d42; //"BM";
bfh.bfSize = sizeof(BITMAPFILEHEADER) + nDIBsize;
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);
#ifdef UNICODE
fp = _wopen(pszFileName, _O_RDWR | _O_CREAT | _O_BINARY, 0);//_S_IREAD | _S_IWRITE );
#else
fp = _open(pszFileName, _O_RDWR | _O_CREAT | _O_BINARY, 0);//_S_IREAD | _S_IWRITE );
#endif
if (fp == 0)
return FALSE;
nSize = _write( fp, &bfh, sizeof(BITMAPFILEHEADER));
nSize = _write( fp, pDIB, nDIBsize);
_close(fp);
GlobalUnlock(hDIB);
return TRUE;
}
L_VOID ExampleChangeToDIB(pBITMAPHANDLE pBitmap, L_TCHAR L_FAR* pszFileName)
{
HGLOBAL hDIB;
hDIB = L_ChangeToDIB(pBitmap, sizeof(BITMAPHANDLE));
//At this point, the original pBitmap is now invalid
MySaveFile(hDIB, TEXT("e:\\erase\\dib2.bmp"));
GlobalFree(hDIB);
}