L_ChangeToDDB

Summary

Changes a LEAD bitmap handle to a Windows Device Dependent Bitmap (DDB).

Syntax

#include "l_bitmap.h"

L_LTDIS_API L_HBITMAP L_ChangeToDDB(hDC, pBitmap)

Parameters

L_HDC hDC

Handle to the device responsible for the conversion. The mapping mode of the device context must be MM_TEXT.

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap to change.

Returns

Value Meaning
>0 HBITMAP.
0 An error occurred.

Comments

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.

Platforms

Win32, x64.

Required DLLs and Libraries

See Also

Functions

Topics

Example

This example loads a bitmap, changes it to a DDB, then changes the DDB back to a bitmap.

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("Image2.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 Version 22.0.2023.7.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.