L_GetBitmapListItem

#include "l_bitmap.h"

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

HBITMAPLIST hList;

/* handle to the list of bitmaps */

L_UINT uIndex;

/* position of the bitmap in the list */

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_UINT uStructSize;

/* size in bytes, of the structure pointed to by pBitmap */

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

Parameter

Description

hList

Handle to the list of bitmaps.

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.

pBitmap

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

uStructSize

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

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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

LTKRN

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 2000 / XP/Vista, Windows CE.

See Also

Functions:

L_LoadBitmapList, L_SaveBitmapList, L_CreateBitmapList, L_DestroyBitmapList, L_CopyBitmapListItems, L_GetBitmapListCount, L_InsertBitmapListItem, L_RemoveBitmapListItem, L_DeleteBitmapListItems, L_SetBitmapListItem, L_ColorResBitmapList, L_TranslateBitmapColor

Topics:

Raster Image Functions: Playing Animated Images

 

Implementing Animation

Example

For complete sample code, refer to the CHILD.C module of the DEMO example. 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;

#if defined (LEADTOOLS_V16_OR_LATER)
   nRet = L_ChangeBitmapHue(&TmpBitmap, i * 10, 0);
#else
   nRet = L_ChangeBitmapHue(&TmpBitmap, i * 10);
#endif
      if(nRet != SUCCESS)
         return nRet;

      if(TmpBitmap.BitsPerPixel<=8)
      {
         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,
                              CRF_NODITHERING|CRF_OPTIMIZEDPALETTE, 
                              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;
}