#include "l_bitmap.h"
L_LTDIS_API L_HBITMAP L_ChangeToDDB(hDC, pBitmap)
Changes a LEAD bitmap handle to a Windows Device Dependent Bitmap (DDB).
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 change.
Value | Meaning |
---|---|
>0 | HBITMAP. |
0 | An error occurred. |
This function results in only one copy of the bitmap, and it invalidates the LEAD bitmap handle.
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.
If you want to load another image using the same bitmap handle, you must initialize the bitmap handle again.
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 */
}
Regions are not supported on the Windows CE platform.
Win32, x64.
Required DLLs and Libraries
This example loads a bitmap, changes it to a DDB, then changes the DDB back to a bitmap.
/* Bitmap handle for the image */
L_INT ChangeToDDBExample(L_HWND hWnd,pBITMAPHANDLE pBitmap)
{
L_INT nRet;
BITMAPHANDLE TmpBitmap; /* Bitmap handle for the initial image */
HBITMAP hDDB; /* Handle for the DDB */
HPALETTE hPalette; /* 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 at 8 bits per pixel so that we can demonstrate palette handling */
nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), &TmpBitmap, sizeof(BITMAPHANDLE), 8, ORDER_BGR, NULL, NULL);
if(nRet != SUCCESS)
return nRet;
/* Duplicate the palette */
hPalette = L_DupBitmapPalette(&TmpBitmap);
/* Change the initial bitmap to a DDB */
hDDB = L_ChangeToDDB( hDC, &TmpBitmap );
/* Change the DDB to a new LEAD bitmap */
if(pBitmap->Flags.Allocated)
L_FreeBitmap(pBitmap);
nRet = L_ChangeFromDDB(hDC, pBitmap, sizeof(BITMAPHANDLE), hDDB, hPalette);
if(nRet != SUCCESS)
return nRet;
/* Clean up */
ReleaseDC( hWnd, hDC );
DeleteObject(hPalette);
if(TmpBitmap.Flags.Allocated)
L_FreeBitmap(&TmpBitmap);
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