Gets a bitmap handle that references a bitmap in a list.


#include "l_bitmap.h"

L_LTKRN_API L_INT L_GetBitmapListItem(hList, uIndex, pBitmap, uStructSize)



Handle to the list of bitmaps.

L_UINT uIndex

Position of the bitmap in the list. Use zero-based indexing. For example, if there are 10 bitmaps in a list, the index of the last one is 9.


Pointer to the bitmap handle that will reference the bitmap in the list.

L_UINT uStructSize

Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).


Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.


The bitmap handle that this function gets is a copy of the bitmap handle stored internally in the list. If you modify the bitmap using this handle, you can update the internal bitmap handle to reflect the changes by using the L_SetBitmapListItem function.

You should not use this handle to free the bitmap. Instead, use L_DeleteBitmapListItems.

You cannot use this function to update a bitmap list while it is being used in an animation playback.

Required DLLs and Libraries


Win32, x64, Linux.

See Also




For complete sample code, refer to the CHILD.C module of the DEMO
This example changes the hue of bitmaps in a list, then updates
the paint palette and the target bitmap's palette for animation playback.
When changing the hue, it preserves the transparent color.

L_INT GetBitmapListItemExample(HWND            hWnd, 
                                              HBITMAPLIST     hList, 
                                              LPRGBQUAD       TransparentColor, 
                                              pBITMAPHANDLE   pBitmap, 
                                              HPALETTE        hpalPaint  /* Paint palette handle */) 
   HDC            hdc;        /* Device context of the current window */ 
   BITMAPHANDLE   TmpBitmap;  /* Temporary bitmap for manipulating the list */ 
   L_UINT         i;          /* Loop counter */ 
   L_UINT         uCount;     /* Number of bitmaps in the list */ 
   L_INT          nRet; 
   /* Change the hue of each bitmap in the list,  
   and restore the transparent color as the last color in the palette */ 
   nRet = L_GetBitmapListCount(hList, &uCount); 
   if(nRet != SUCCESS) 
      return nRet; 
   for (i = 0; i < uCount; ++i) 
      nRet = L_GetBitmapListItem(hList, i, &TmpBitmap, sizeof(BITMAPHANDLE)); 
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = L_ChangeBitmapHue(&TmpBitmap, i * 10, 0); 
      if(nRet != SUCCESS) 
         return nRet; 
         nRet = L_PutBitmapColors(&TmpBitmap, 255, 1, TransparentColor); 
         if(nRet != SUCCESS) 
            return nRet; 
      nRet = L_SetBitmapListItem(hList, i, &TmpBitmap); 
      if(nRet != SUCCESS) 
         return nRet; 
   /* Get an optimized palette for the whole list */ 
   nRet = L_ColorResBitmapList(hList, 8, 
                              NULL, NULL, 0); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Update the paint palette that is used for playback */ 
   nRet = L_GetBitmapListItem(hList, 0, &TmpBitmap, sizeof(BITMAPHANDLE)); 
   if(nRet != SUCCESS) 
      return nRet; 
   hdc = GetDC (hWnd); 
   hpalPaint = L_CreatePaintPalette (hdc, &TmpBitmap); 
   ReleaseDC (hWnd, hdc); 
   /* Update the target bitmap's background color, based on the new palette */ 
   pBitmap->Background = L_TranslateBitmapColor(&TmpBitmap, pBitmap, pBitmap->Background); 
   /* Copy the new palette to the target bitmap */ 
   nRet = L_CopyBitmapPalette(pBitmap, &TmpBitmap); 
   return nRet; 

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.