L_ProcessPlayback (original) (raw)

Summary

Processes the next state during an animation playback.

Syntax

#include "l_bitmap.h"

L_LTDIS_API L_INT L_ProcessPlayback(hPlayback, puState)

Parameters

HPLAYBACK hPlayback

Handle that references the animation playback.

L_UINT* puState

Address of the variable to be updated with a constant that describes the new state of the animation playback engine. For possible values, refer to Animation Playback States.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

This function is called in a loop to continually process the playback.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example loads a bitmap list from an animated GIF or WEBP file.
It then plays the animation, using the current bitmap as the target.

L_INT ProcessPlaybackExample(L_HWND hWnd, pBITMAPHANDLE pBitmap, L_TCHAR * pszFilename) { L_INT nRet; HBITMAPLIST hList; /* Bitmap list */ BITMAPHANDLE TmpBitmap; /* Temporary bitmap for building 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 */ HPALETTE hpalPaint; /* Create the bitmap list from the input file (GIF or AVI) */ nRet = L_LoadBitmapList(pszFilename, &hList, 0, 0, NULL, NULL); if (nRet != SUCCESS) return nRet; /* Get a copy of the first image's bitmap handle */ nRet = L_GetBitmapListItem(hList, 0, &TmpBitmap, sizeof(BITMAPHANDLE)); if (nRet != SUCCESS) { L_DestroyBitmapList(hList); return nRet; } /* Create the palette that is used for playback. Not necessary for WEBP animations */ hdc = GetDC(hWnd); hpalPaint = L_CreatePaintPalette(hdc, &TmpBitmap); ReleaseDC(hWnd, hdc); /* Use the client area as the display rectangle, assuming that the window is properly sized */ GetClientRect(hWnd, &rcDisplay); /* Create the target bitmap that is used for playback */ if (pBitmap->Flags.Allocated) L_FreeBitmap(pBitmap); nRet = L_CreateBitmap(pBitmap, sizeof(BITMAPHANDLE), TYPE_CONV, TmpBitmap.Width, TmpBitmap.Height, TmpBitmap.BitsPerPixel, TmpBitmap.Order, NULL, TmpBitmap.ViewPerspective, NULL, 0); if (nRet != SUCCESS) { L_DestroyBitmapList(hList); return nRet; } /* Update the palette of the target bitmap. Not necessary for WEBP animations */ nRet = L_CopyBitmapPalette(pBitmap, &TmpBitmap); if (nRet != SUCCESS) { L_DestroyBitmapList(hList); return nRet; } /* Create and run the playback */ nRet = L_CreatePlayback(&hPlayback, pBitmap, hList); if (nRet != SUCCESS) { L_DestroyBitmapList(hList); return nRet; } do { nRet = L_ProcessPlayback(hPlayback, &uState); if (nRet != SUCCESS) break; switch (uState) { case PLAYSTATE_WAITINPUT: /* This is necessary only for GIF animations. Normally, you will have to wait for the user to press a key here. But we will keep it simple and call L_CancelPlaybackWait to cancel the wait for a key */ nRet = L_CancelPlaybackWait(hPlayback); if (nRet != SUCCESS) break; break; case PLAYSTATE_POSTCLEAR: case PLAYSTATE_POSTRENDER: nRet = L_GetPlaybackUpdateRect(hPlayback, &rcUpdate, TRUE); if (nRet != SUCCESS) break; hdc = GetDC(hWnd); if (hpalPaint) { hPalette = SelectPalette(hdc, hpalPaint, TRUE); RealizePalette(hdc); } nRet = L_PaintDC(hdc, pBitmap, NULL, &rcUpdate, &rcDisplay, &rcDisplay, SRCCOPY); /* if nRet != SUCCESS, we will release the DC and break out of the loop because nRet is not SUCCESS */ if (hpalPaint) SelectPalette(hdc, hPalette, TRUE); ReleaseDC(hWnd, hdc); break; } } while (uState != PLAYSTATE_END && nRet == SUCCESS); /* Clean up */ nRet = L_DestroyPlayback(hPlayback, NULL); if (nRet != SUCCESS) return nRet; nRet = L_DestroyBitmapList(hList); return nRet; }