Updating Old Code to Use the New Palette Mechanism

As of version 13, the BITMAPHANDLE structure has changed and new functions have been added to allow the user to limit the number of GDI resources LEAD bitmaps require. This change could cause existing source code to no longer compile. However, this change WILL NOT affect existing applications/binaries. The purpose of this change is to allow users to load many images, without each using up GDI resources by creating an HPALETTE. The former (and default) behavior is that for each image that is loaded from file, an HPALETTE GDI object is created. With these new functions/features, you can avoid this. The BITMAPHANDLE structure has changed. The hPalette member has been changed to Palette.hPalette. If your code was accessing the hPalette member directly, you will need to modify your code when you re-compile.

The following are scenarios where you could have accessed hPalette directly, and examples of how you should change your code:

If you were doing a simple test of hPalette:

if(pBitmap->hPalette) 

then you should change your code to:

if(pBitmap->Palette.hPalette) 

If you were copying a palette from one bitmap to another:

BitmapDst.hPalette = BitmapSrc.hPalette; 

then you should use L_CopyBitmapPalette():

L_CopyBitmapPalette(&BitmapDst, &BitmapSrc); 

If you were duplicating the hPalette or copying a reference to the hPalette:

hPalette = pBitmap->hPalette; 

then you should use L_DupBitmapPalette, and delete the hPalette when you no longer need it.:

hPalette = L_DupBitmapPalette;   
// use the palette   
DeleteObject(hPalette);" 

If you were assigning the bitmap's hPalette:

BitmapDst.hPalette = hPalette; 

then you should use L_SetBitmapPalette:

L_SetBitmapPalette(&Bitmap, hPalette);   
DeleteObject(hPalette); 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help