L_AppendPlayback

#include "l_bitmap.h"

L_LTDIS_API L_INT L_AppendPlayback(hPlayback, pBitmap)

Appends a bitmap to a bitmap list during an animation playback.

Parameters

HPLAYBACK hPlayback

Handle that references the animation playback.

pBITMAPHANDLE pBitmap

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.

Returns

Value Meaning
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

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

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 Version 20.0.2019.12.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help