Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_AppendPlayback
#include "l_bitmap.h"
L_LTDIS_API L_INT 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
Win32, x64, Mobile.
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.
static BITMAPHANDLE Bitmap; /* bitmap for the playback bitmap */ static BITMAPHANDLE Bitmap2; /* bitmap to hold loaded frames */ static 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; extern L_INT PlayProcessing(PLAYCALLBACKDATA* pAnimData); /* function prototypes */ L_INT AppendPlaybackExample(HWND hWndChild,L_TCHAR* szFile); /* Prototype for the FILEREADCALLBACK function */ L_INT EXT_CALLBACK PlayCallBack(pFILEINFO pFileInfo, pBITMAPHANDLE pBitmap, L_UCHAR* pBuffer, L_UINT uFlags, L_INT nRow, L_INT nLines, PLAYCALLBACKDATA* pData); /***************** calling function *******************/ L_INT AppendPlaybackExample(HWND hWnd,L_TCHAR* 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 */ nRet = L_LoadBitmap(szFile, &Bitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet != SUCCESS) return nRet; 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); if(nRet != SUCCESS) return nRet; 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); if(nRet != SUCCESS) return nRet; 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 EXT_CALLBACK PlayCallBack(pFILEINFO pFileInfo, pBITMAPHANDLE pBitmap, L_UCHAR* pBuffer, L_UINT uFlags, L_INT nRow, L_INT nLines, PLAYCALLBACKDATA* pData) { UNREFERENCED_PARAMETER(pFileInfo); UNREFERENCED_PARAMETER(pBuffer); L_UINT uState; RECT rcUpdate; L_INT nRet; if (uFlags & FILEREAD_FIRSTROW) { nRet = L_AppendPlayback(pData->hPlayback, pBitmap); if(nRet != SUCCESS) return(nRet); } nRet = L_ValidatePlaybackLines(pData->hPlayback, nRow, nLines); if(nRet != SUCCESS) return nRet; nRet = L_GetPlaybackState(pData->hPlayback, &uState); if(nRet != SUCCESS) return nRet; while(uState != PLAYSTATE_END) { nRet = L_ProcessPlayback(pData->hPlayback, &uState); if(nRet != SUCCESS) return nRet; switch(uState) { case PLAYSTATE_WAITINPUT: nRet = L_CancelPlaybackWait(pData->hPlayback); if(nRet != SUCCESS) return nRet; break; case PLAYSTATE_POSTCLEAR: case PLAYSTATE_POSTRENDER: nRet = L_GetPlaybackUpdateRect(pData->hPlayback, &rcUpdate, TRUE); if(nRet != SUCCESS) return nRet; nRet = L_PaintDC (pData->hDC, &Bitmap, NULL, &rcUpdate, &pData->rcPaint, NULL, SRCCOPY); if(nRet != SUCCESS) return nRet; break; } break; } return(SUCCESS); }