L_ChangeToDDB

#include "l_bitmap.h"

L_LTDIS_API L_HBITMAP L_ChangeToDDB(hDC, pBitmap)

L_HDC hDC;

/* handle to the device responsible for the conversion */

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

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

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 change.

Returns

>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 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 */
   }

 

Regions are not supported on the Windows CE platform.

Platforms

Win32, x64, Mobile.

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.

See Also

Functions:

L_ConvertFromDDB, L_ConvertFromDIB,

 

L_ConvertToDDB, L_ConvertToDIB,

 

L_ChangeFromDDB, L_ChangeFromDIB,

 

L_ChangeToDIB

Topics:

Raster Image Functions: Creation, Deletion, and Copying

 

Using DIBs, DDBs, and the Clipboard

Example

/* 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;
}