Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_ConvertToDDB
#include "l_bitmap.h"
L_LTDIS_API L_HBITMAP L_ConvertToDDB(hDC, pBitmap)
L_HDC hDC; |
/* handle to the device responsible for the conversion */ |
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
Converts a LEAD Technologies bitmap into a Windows device dependent bitmap (DDB). When this function is completed, there are two copies of the image in memory: the DDB and the original LEAD bitmap. Freeing one will not affect the other.
Parameter |
Description |
hDC |
Handle to the device responsible for the conversion. The mapping mode of the device context must be MM_TEXT. |
pBitmap |
Pointer to the bitmap handle referencing the bitmap to copy. |
Returns
This function returns a handle to the DDB, or it returns a NULL if there is an error.
Comments
This function allocates a DDB bitmap and copies the LEAD bitmap to the DDB.
If this function fails, the return value is a NULL HBITMAP. This can happen if the image is too large for the Windows C DLL functions that LEADTOOLS uses internally. To get more information about why the Windows C DLL functions may have failed, you can use the Windows C DLL GetLastError.
/* Change the initial bitmap to a DDB */
hDDB = L_ChangeToDDB( hDC, &Bitmap );
if(!hDDB)
{
DWORD dwRet = GetLastError();
/* process the error code here */
}
Required DLLs and Libraries
LTDIS 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 2000 / XP/Vista, Windows CE.
See Also
Functions: |
|
|
|
|
|
|
|
Topics: |
|
|
Example
For complete sample code, refer to the DIBDDB example. This example loads a bitmap, converts it to a DDB, then converts the DDB back to a bitmap.
L_INT ConvertToDDBExample(L_HWND hWnd,pBITMAPHANDLE pLeadBitmap) { L_INT nRet; BITMAPHANDLE TmpBitmap; /* Bitmap handle for the initial image */ HBITMAP hDDB; /* Handle for the DDB */ HPALETTE hPalette; /* Palette handle */ HPALETTE hpalSave = NULL; /* Saved palette handle */ HDC hDC; /* Handle to the device context for the current window */ /* Get the device context for the current window */ hDC = GetDC( hWnd ); /* Load a bitmap, keeping its own bits per pixel */ nRet = L_LoadBitmap (TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\image3.cmp"), &TmpBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet != SUCCESS) return nRet; hPalette = L_CreatePaintPalette(hDC, &TmpBitmap); if (hPalette) { hpalSave = SelectPalette(hDC, hPalette, FALSE); RealizePalette(hDC); } /* Convert the initial bitmap to a DDB */ hDDB = L_ConvertToDDB( hDC, &TmpBitmap ); if (hPalette) SelectPalette(hDC, hpalSave, FALSE); /* Free the initial bitmap */ L_FreeBitmap(&TmpBitmap); /* Convert the DDB to create a new LEAD bitmap */ nRet = L_ConvertFromDDB(hDC, pLeadBitmap, sizeof(BITMAPHANDLE), hDDB, hPalette); if(nRet != SUCCESS) return nRet; /* Clean up */ ReleaseDC( hWnd, hDC ); DeleteObject(hDDB); DeleteObject(hPalette); return SUCCESS; }