L_CreateBitmapList
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_CreateBitmapList(phList)
pHBITMAPLIST phList; |
/* address of the variable to be updated */ |
Creates an empty list of LEAD bitmaps. The list can then be built and maintained with related functions.
Parameter |
Description |
phList |
Address of the HBITMAPLIST variable for the new list. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
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: |
|
|
|
|
|
|
|
|
|
|
|
Topics: |
|
|
Example
/* This example creates a bitmap list from the current bitmap, rotating each copy by 10 degrees.
It defines the rotation fill color as a transparent color, and assigns an animation background color.
It then plays the animation, using the current bitmap as the target. */
HPALETTE hpalPaint; /* Paint palette handle. */
BITMAPHANDLE LeadBitmap; /* Bitmap handle for the loaded image. */
void TestFunction(HWND hWnd)
{
HBITMAPLIST hList; /* Bitmap list */
BITMAPHANDLE TmpBitmap; /* Temporary bitmap for building the list */
L_INT nMax = 160; /* Maximum width or height for bitmaps in the list */
HPLAYBACK hPlayback; /* Animation playback */
L_UINT uState; /* Next state in the playback */
RECT rcUpdate; /* Source clipping rectangle used in playback */
RECT rcDisplay; /* Display rectangle used in playback */
HDC hdc; /* Device context of the current window */
HPALETTE hPalette = NULL; /* Temporary copy of the current system palette */
RGBQUAD TmpPalette[1]; /* Palette to define the transparent color */
L_INT i; /* Loop counter */
/* Reduce memory requirements, if necessary. Only small bitmaps play smoothly. */
if (LeadBitmap.Width > nMax)
L_SizeBitmap (&LeadBitmap, nMax, (LeadBitmap.Height * nMax) / LeadBitmap.Width, SIZE_RESAMPLE);
else if (LeadBitmap.Height > nMax)
L_SizeBitmap (&LeadBitmap, (LeadBitmap.Width * nMax) / LeadBitmap.Height, nMax, SIZE_RESAMPLE);
/* Dither to an optimized palette, leaving the last color blank to use
later for transparency */
L_ColorResBitmap(&LeadBitmap, &LeadBitmap, sizeof(BITMAPHANDLE), 8,
CRF_FLOYDSTEINDITHERING|CRF_OPTIMIZEDPALETTE|CRF_IDENTITYPALETTE,
NULL, NULL, 255, NULL, NULL);
/* Set the transparent color in the last position of the palette */
TmpPalette[0].rgbBlue = (BYTE) 202;
TmpPalette[0].rgbGreen = (BYTE) 222;
TmpPalette[0].rgbRed = (BYTE) 212;
L_PutBitmapColors(&LeadBitmap, 255, 1, TmpPalette);
/* Create the paint palette */
hdc = GetDC (hWnd);
hpalPaint = L_CreatePaintPalette (hdc, &LeadBitmap);
ReleaseDC (hWnd, hdc);
/* Set the playback flags that will apply to all bitmaps in the list */
LeadBitmap.Flags.WaitUserInput = FALSE;
LeadBitmap.Flags.Transparency = TRUE;
LeadBitmap.Left = 0;
LeadBitmap.Top = 0;
LeadBitmap.Delay = 10;
LeadBitmap.Transparency = PALETTEINDEX(255); /* Last color in the palette */
LeadBitmap.DisposalMethod = PLAYDISPOSE_RESTOREBACKGROUND;
/* Create and populate the bitmap list */
L_CreateBitmapList(&hList);
for (i = 0; i <= 36; ++ i)
{
L_CopyBitmap(&TmpBitmap, &LeadBitmap, sizeof(BITMAPHANDLE));
/* Rotate, using the transparent color as the fill color */
L_RotateBitmap (&TmpBitmap, 1000 * i, 0, PALETTEINDEX(255));
L_InsertBitmapListItem(hList, (L_UINT)-1, &TmpBitmap);
}
/* Set the background color for the animation playback */
LeadBitmap.Background = RGB(0,0,255);
/* Use the client area as the display rectangle */
GetClientRect(hWnd,&rcDisplay);
/* Create and run the playback */
L_CreatePlayback(&hPlayback, &LeadBitmap, hList);
do
{
L_ProcessPlayback(hPlayback, &uState);
switch(uState)
{
case PLAYSTATE_POSTRENDER:
L_GetPlaybackUpdateRect(hPlayback, &rcUpdate, TRUE);
hdc = GetDC(hWnd);
if (hpalPaint)
{
hPalette = SelectPalette (hdc, hpalPaint, TRUE);
RealizePalette(hdc);
}
L_PaintDC (hdc, &LeadBitmap, NULL, &rcUpdate, &rcDisplay, &rcDisplay, SRCCOPY);
if (hpalPaint)
SelectPalette (hdc, hPalette, TRUE);
ReleaseDC(hWnd, hdc);
break;
}
} while(uState != PLAYSTATE_END);
/* Clean up */
L_DestroyPlayback(hPlayback, NULL);
L_DestroyBitmapList(hList);
return;
}