L_AppendPlayback
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_AppendPlayback(hPlayback, pBitmap)
HPLAYBACK hPlayback; |
/* playback handle */ |
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
Appends a bitmap to a bitmap list during an animation playback.
Parameter |
Description |
hPlayback |
Handle that references the animation playback. |
pBitmap |
Pointer to the bitmap handle that references the bitmap to append. The specified bitmap must be fully allocated, although the image data is not yet loaded when this function is called. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
If you pass NULL in the hList parameter of the L_CreatePlayback function, you can use the L_AppendPlayback function to add bitmaps to the list during the playback. This is useful in the FILEREADCALLBACK function if you want to play an animated file as it is being loaded. If you need to reference the list after the playback, you can pass the address of an HBITMAPLIST variable when you call the L_DestroyPlayback function.
The L_ValidatePlaybackLines function lets you validate the lines that the animation playback engine will render to the target bitmap.
Required DLLs and Libraries
LTDIS 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: |
Raster Image Functions: Creating and Maintaining Lists of Images |
|
Example
For complete sample code, refer to the FRAME.C module of the DEMO example.
/****************************************************************************************
This example plays an animated GIF or AVI file as it loads the file. The example includes both
the calling function and the FILEREADCALLBACK function, which displays the image.
The sample code uses the following global declarations: */
BITMAPHANDLE Bitmap; /* bitmap for the playback bitmap */
BITMAPHANDLE Bitmap2; /* bitmap to hold loaded frames */
HINSTANCE hInst; /* Current instance of the application, set by the InitInstance function */
/* Structure used for the callback function's user data */
typedef struct tagPLAYCALLBACKDATA
{
HPALETTE hPalette; /* old palette saved from callback */
HWND hWnd; /* window to paint */
HDC hDC; /* hdc of window to paint */
RECT rcPaint; /* windows client rectangle */
HPLAYBACK hPlayback;
} PLAYCALLBACKDATA;
/* function prototypes */
static L_INT PlayWhileLoad (HWND hWndChild, L_TCHAR L_FAR*szFile);
/* Prototype for the FILEREADCALLBACK function */
L_INT L_FAR L_EXPORT PlayCallBack(pFILEINFO pFileInfo,
pBITMAPHANDLE pBitmap,
L_UCHAR L_FAR *pBuffer,
L_UINT uFlags,
L_INT nRow,
L_INT nLines,
PLAYCALLBACKDATA L_FAR * pData);
/***************** calling function *******************/
static L_INT PlayWhileLoad (HWND hWnd, L_TCHAR L_FAR*szFile)
{
L_INT nRet;
FILEREADCALLBACK lpfnCallBack;
PLAYCALLBACKDATA AnimData;
HPALETTE hOldPal=NULL;
AnimData.hWnd = hWnd;
AnimData.hDC = GetDC(hWnd);
AnimData.hPalette = NULL;
GetClientRect(hWnd, &AnimData.rcPaint);
/* load the first frame, so we have the palette and a target bitmap for playback */
L_LoadBitmap(szFile, &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
AnimData.hPalette = L_CreatePaintPalette(AnimData.hDC, &Bitmap);
if(AnimData.hPalette)
{
hOldPal = SelectPalette(AnimData.hDC, AnimData.hPalette, FALSE);
RealizePalette(AnimData.hDC);
}
nRet = L_CreatePlayback(&AnimData.hPlayback, &Bitmap, NULL);
lpfnCallBack = (FILEREADCALLBACK) MakeProcInstance ((FARPROC) PlayCallBack, hInst);
nRet = L_LoadFile (szFile, &Bitmap2, sizeof(BITMAPHANDLE), 24,
ORDER_BGR,
LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_ALLPAGES,
lpfnCallBack, &AnimData, NULL, NULL);
PlayProcessing(&AnimData);
FreeProcInstance ((FARPROC) lpfnCallBack);
if(AnimData.hPalette)
{
SelectPalette(AnimData.hDC, hOldPal, FALSE);
DeleteObject(AnimData.hPalette);
}
ReleaseDC (hWnd, AnimData.hDC);
L_DestroyPlayback(AnimData.hPlayback, NULL);
L_FreeBitmap(&Bitmap);
L_FreeBitmap(&Bitmap2);
return(nRet);
}
L_INT L_FAR L_EXPORT PlayCallBack(pFILEINFO pFileInfo,
pBITMAPHANDLE pBitmap,
L_UCHAR L_FAR *pBuffer,
L_UINT uFlags,
L_INT nRow,
L_INT nLines,
PLAYCALLBACKDATA L_FAR * pData)
{
L_UINT uState;
RECT rcUpdate;
L_INT nRet;
if (uFlags & FILEREAD_FIRSTROW)
{
nRet = L_AppendPlayback(pData->hPlayback, pBitmap);
if(nRet != SUCCESS)
return(nRet);
}
L_ValidatePlaybackLines(pData->hPlayback, nRow, nLines);
L_GetPlaybackState(pData->hPlayback, &uState);
while(uState != PLAYSTATE_END)
{
L_ProcessPlayback(pData->hPlayback, &uState);
switch(uState)
{
case PLAYSTATE_WAITINPUT:
L_CancelPlaybackWait(pData->hPlayback);
break;
case PLAYSTATE_POSTCLEAR:
case PLAYSTATE_POSTRENDER:
L_GetPlaybackUpdateRect(pData->hPlayback, &rcUpdate, TRUE);
L_PaintDC (pData->hDC, &Bitmap, NULL, &rcUpdate, &pData->rcPaint, NULL, SRCCOPY);
break;
}
break;
}
return(SUCCESS);
}