#include "l_bitmap.h"
L_LTDIS_API L_HBITMAP L_ConvertToDDB(hDC, pBitmap)
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.
Handle to the device responsible for the conversion. The mapping mode of the device context must be MM_TEXT.
Pointer to the bitmap handle referencing the bitmap to copy.
This function returns a handle to the DDB, or it returns a NULL if there is an error.
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 API functions that LEADTOOLS uses internally. To get more information about why the Windows C API functions may have failed, you can use the Windows C API 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
Win32, x64.
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 (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\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;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document