L_ConvertToDDB

#include "l_bitmap.h"

HBITMAP EXT_FUNCTION L_ConvertToDDB(hDC, pBitmap)

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.

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 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_ConvertFromDDB, L_ConvertFromDIB,

 

L_ConvertToDIB, L_ChangeFromDDB,

 

L_ChangeFromDIB, L_ChangeToDDB,

 

L_ChangeToDIB

Topics:

Raster Image Functions: Creation, Deletion, and Copying

 

Using DIBs, DDBs, and the Clipboard

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 */
void LeadDDBLead(HWND hWnd, pBITMAPHANDLE pLeadBitmap)
{
   BITMAPHANDLE TmpBitmap;    /* Bitmap handle for the initial image */
   HBITMAP hDDB; /* Handle for the DDB */
   HPALETTE hPalette; /* Palette handle */
   HPALETTE hpalSave; /* 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 */
   L_LoadBitmap (TEXT("image3.cmp"), &TmpBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   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 */
   L_ConvertFromDDB(hDC, pLeadBitmap, sizeof(BITMAPHANDLE), hDDB, hPalette);
   /* Clean up */
   ReleaseDC( hWnd, hDC );
   DeleteObject(hDDB);
   DeleteObject(hPalette);
   return;
}