#include "l_bitmap.h"
L_LTDIS_API L_INT L_AppendPlayback(hPlayback, pBitmap)
Appends a bitmap to a bitmap list during an animation playback.
Handle that references the animation playback.
Pointer to the bitmap handle that references the bitmap to append. The specified bitmap must be fully allocated, even though the image data is not yet loaded when this function is called.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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
Win32, x64, Linux.
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 */
L_INT PlayProcessing(PLAYCALLBACKDATA* pAnimData);
/* 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,
L_VOID * pUserData);
/***************** calling function *******************/
L_INT AppendPlaybackExample(HWND hWnd,L_TCHAR* szFile)
{
L_INT nRet;
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;
nRet = L_LoadFile (szFile,
&Bitmap2,
sizeof(BITMAPHANDLE),
24,
ORDER_BGR,
LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_ALLPAGES,
PlayCallBack,
&AnimData,
NULL,
NULL);
if(nRet != SUCCESS)
return nRet;
PlayProcessing(&AnimData);
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 PlayProcessing(PLAYCALLBACKDATA* pAnimData)
{
HDC hDc;
hDc = pAnimData->hDC;
/*Play your process*/
return SUCCESS;
}
L_INT EXT_CALLBACK PlayCallBack(pFILEINFO pFileInfo,
pBITMAPHANDLE pBitmap,
L_UCHAR* pBuffer,
L_UINT uFlags,
L_INT nRow,
L_INT nLines,
L_VOID * pUserData)
{
UNREFERENCED_PARAMETER(pFileInfo);
UNREFERENCED_PARAMETER(pBuffer);
L_UINT uState;
RECT rcUpdate;
L_INT nRet;
PLAYCALLBACKDATA* pData = (PLAYCALLBACKDATA*)pUserData;
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);
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document