L_GetBitmapListItem

#include "l_bitmap.h"

L_INT EXT_FUNCTION 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 95 / 98 / Me, Windows 2000 / XP, 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. */
BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the target bitmap */
HPALETTE hpalPaint;        /* Paint palette handle */
void TestList(HWND hWnd, HBITMAPLIST hList, LPRGBQUAD TransparentColor)
{
   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 */
   /* Change the hue of each bitmap in the list, 
   and restore the transparent color as the last color in the palette */
   L_GetBitmapListCount(hList, &uCount);
   for (i = 0; i < uCount; ++i)
   {
      L_GetBitmapListItem(hList, i, &TmpBitmap, sizeof(BITMAPHANDLE));
      L_ChangeBitmapHue(&TmpBitmap, i * 10);
      L_PutBitmapColors(&TmpBitmap, 255, 1, TransparentColor);
      L_SetBitmapListItem(hList, i, &TmpBitmap);
   }
   /* Get an optimized palette for the whole list */
   L_ColorResBitmapList(hList, 8,
                 CRF_NODITHERING|CRF_OPTIMIZEDPALETTE, 
                 NULL, NULL, 0);
   /* Update the paint palette that is used for playback */
   L_GetBitmapListItem(hList, 0, &TmpBitmap, sizeof(BITMAPHANDLE));
   hdc = GetDC (hWnd);
   hpalPaint = L_CreatePaintPalette (hdc, &TmpBitmap);
   ReleaseDC (hWnd, hdc);
   /* Update the target bitmap's background color, based on the new palette */
   LeadBitmap.Background = L_TranslateBitmapColor(&TmpBitmap, &LeadBitmap, 
      LeadBitmap.Background);
   /* Copy the new palette to the target bitmap */
   L_CopyBitmapPalette(&LeadBitmap, &TmpBitmap);
}