L_AppendPlayback

Summary

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

Syntax

#include "l_bitmap.h"

L_LTDIS_API L_INT L_AppendPlayback(hPlayback, pBitmap)

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

typedef struct tagCHILDDATA 
{ 
   HPALETTE hPalette;           /* palette handle used by PaintDevice */ 
   L_BOOL fFitImage;            /* if TRUE then fit image to window */ 
   L_INT cxClient;              /* width of client area */ 
   L_INT cyClient;              /* height of client area */ 
   L_INT nHScrollPos;           /* x scroll position */ 
   L_INT nVScrollPos;           /* y scroll position */ 
   L_INT nHScrollMax;           /* maximum x scroll position */ 
   L_INT nVScrollMax;           /* maximum y scroll position */ 
   L_INT nHScrollStep;          /* x scroll step value */ 
   L_INT nVScrollStep;          /* y scroll step value */ 
   L_INT nHScrollFactor;        /* the multiply factor for the horizontal scrollbar */ 
   L_INT nVScrollFactor;        /* the multiply factor for the vertical scrollbar */ 
   L_BOOL bThumbTrack; 
   L_INT nZoom; 
   RECT rcView; 
   L_TCHAR szTitle[_MAX_PATH]; 
   L_TCHAR szFileName[_MAX_PATH]; 
   L_UINT uTitleCount; 
   L_BOOL fComposite; 
   L_UINT uFrame; 
   L_UINT uLastFrame; 
   L_BOOL fLoop; 
   BITMAPHANDLE ActiveBitmap; 
   BITMAPHANDLE Bitmap;         /* open BITMAPHANDLE */ 
   HBITMAPLIST hList; 
   L_UINT uFrameType; 
   BOOL  bMovingFloater; 
   HBITMAP hbmSave, hbmFloater; 
   HRGN  hrgnRegion, hrgnFloater; 
   L_INT xSaveSrc, ySaveSrc;     /* the point where the region was in bitmap coordinates */ 
   L_INT xMoveSrc, yMoveSrc;     /* the point where the region was in bitmap coordinates */ 
   L_INT nMoveWidth, nMoveHeight;/* region width and height in bitmap coordinates */ 
   L_INT xAnchor, yAnchor;       /* the last point of the mouse cursor in client coordinates */ 
   L_INT deltaX, deltaY;         /* the distance in client coordinates from the initial position */ 
   L_INT xFloaterDest, yFloaterDest;   /* the last position of the floater, in client coordinates */ 
   L_INT nFloaterWidth, nFloaterHeight; /* floater width & height in client coordinates */ 
   BITMAPHANDLE   bmFloater, bmSave; 
   L_HWND hBitmapWnd; 
   L_HWND hListBox; 
   L_INT nCurrentPage; 
   BOOL  bListBoxVisible; 
   L_INT nLastCy; 
   L_BOOL bImageChanged; 
   L_BOOL bSizeFixed; 
   L_BOOL bGifAnimationFile; 
   L_BOOL bAnimationExist; 
   //for pan window 
   L_HWND hPanWindow; 
   L_BOOL bUpdatePan; 
   L_BOOL bPanWindow; 
   L_BOOL   bPicturizeStarted;      // used only for L_PicturizeBitmap 
   L_BOOL   bFixedPaletteCreated;   // used only for L_PicturizeBitmap 
   HPALETTE hFixedPalette;          // used only for L_PicturizeBitmap 
   L_BOOL bMagGlass; 
   L_BOOL bWasMagGlass; 
   L_UINT32 ulPanDisFlags; 
} CHILDDATA, * LPCHILDDATA; 
 
typedef struct tagPLAYCALLBACKDATA 
{ 
   LPCHILDDATA pChild; 
   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; 
 
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; 
 
   FILEINFO fi; 
   memset(&fi, 0, sizeof(FILEINFO)); 
   fi.uStructSize = sizeof(FILEINFO); 
   fi.Flags = 0; 
 
   nRet = L_LoadFile(szFile, &Bitmap2, sizeof(BITMAPHANDLE), 24, ORDER_BGR, 
      LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_ALLPAGES, 
      PlayCallBack, &AnimData, NULL, &fi); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   PlayProcessing(&AnimData); 
 
   if (AnimData.hPalette) 
   { 
      SelectPalette(AnimData.hDC, hOldPal, FALSE); 
      DeleteObject(AnimData.hPalette); 
   } 
 
   ReleaseDC(hWnd, AnimData.hDC); 
   nRet = 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 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.