LPlayBack::Append

#include "ltwrappr.h"

virtual L_INT LPlayBack::Append(pLBitmap)

LBitmapBase * pLBitmap;

/* pointer to an LBitmapBase object */

Appends a bitmap to a the class object's bitmap list during an animation playback.

Parameter

Description

pLBitmap

Pointer to the bitmap object to be appended to the playback animation. 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 pLBitmapList parameter of the LPlayBack::Create function, you can use the LPlayBack::Append function to add bitmaps to the list during the playback. This is useful in the LFile objects load callback functions 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 LBitmapList variable when you call the LPlayBack::Destroy function.

The LPlayBack::ValidateLines function lets you validate the lines that the animation playback engine will render to the target bitmap.

Required DLLs and Libraries

LTDIS
LTFIL

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.

See Also

Functions:

Class Members

Topics:

Raster Image Functions: Creating and Maintaining Lists of Images

 

Implementing Animation

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
class LPBUserFile : public LFile
{
   HPALETTE m_hPalette;
   HWND m_hWnd;
   HDC m_hDC;
   RECT m_rcPaint;
public:
   LPlayBack m_PlayBack; // playback handle 
      LPBUserFile(HWND hwnd, LBitmapBase *pBitmapBase);
      virtual ~LPBUserFile();
      virtual    L_INT  LoadFileCallBack(pFILEINFO pFileInfo,
                                         LBitmapBase * pLBitmap,
                                         LBuffer * pLBuffer,
                                         L_UINT uFlags,
                                         L_INT nRow,
                                         L_INT nLines);
   virtual L_INT LoadFile(L_INT nBitsPerPixel=0,
                          L_INT nOrder=ORDER_BGR);
};
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
LPBUserFile::LPBUserFile(HWND hwnd, LBitmapBase *pBitmapBase):LFile(pBitmapBase)
{
   m_hWnd = hwnd;
   m_hDC = GetDC(m_hWnd); // DC will be released in the destructor
   GetClientRect(m_hWnd, &m_rcPaint);
   // Enable LoadInfoCallBack
   EnableCallBack(TRUE);
}
LPBUserFile::~LPBUserFile()
{
   ReleaseDC(m_hWnd, m_hDC);
}
L_INT  LPBUserFile::LoadFileCallBack(
                              pFILEINFO pFileInfo,
                              LBitmapBase *pBitmap,
                              LBuffer * pLBuffer,
                              L_UINT uFlags,
                              L_INT nRow,
                              L_INT nLines
                            )
{
   UNREFERENCED_PARAMETER(pFileInfo);
   UNREFERENCED_PARAMETER(pLBuffer);
   L_INT nRet;    // Return value 
   L_UINT uState; // Next state in the playback 
   RECT rcUpdate; // Source clipping rectangle used in playback 
   L_INT nCounter;
   // If this is the first row of a bitmap ... 
   if (uFlags & FILEREAD_FIRSTROW)
   {
      // Append the bitmap to the list 
      nRet = m_PlayBack.Append(pBitmap);
      if(nRet != SUCCESS)
         return(nRet);
   }
   // Validate the lines in the bitmap so that we can paint them 
   m_PlayBack.ValidateLines(nRow, nLines);
   uState = m_PlayBack.GetState ();
   while(uState != PLAYSTATE_END)
   {
      // Play the animation 
      uState = m_PlayBack.Process();
      switch(uState)
      {
         case PLAYSTATE_WAITINPUT:
         case PLAYSTATE_WAITDELAY  :
            if (m_PlayBack.GetDelay () > 10)
               m_PlayBack.CancelWait ();
            
            break;
      case PLAYSTATE_POSTCLEAR:
      case PLAYSTATE_POSTRENDER:
            m_PlayBack.GetUpdateRect(&rcUpdate, TRUE);
            m_PlayBack.GetBitmap()->SetClipSrcRect(&rcUpdate);
            m_PlayBack.GetBitmap()->SetDstRect(&m_rcPaint);
            m_PlayBack.GetBitmap()->Paint()->SetDC(m_hDC);
            m_PlayBack.GetBitmap()->CreatePaintPalette (m_hDC);
            m_PlayBack.GetBitmap()->Paint()->PaintDC();
            break;
      }
    nCounter  = m_PlayBack.GetIndex();
   // do any processing on specific indexes
      break;
   }
   return(SUCCESS);
} 
L_INT LPBUserFile::LoadFile(L_INT nBitsPerPixel,L_INT nOrder)
{
   m_PlayBack.Create (m_pBitmap);
   return LFile::LoadFile (nBitsPerPixel, nOrder, LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_ALLPAGES);
}
L_INT LPlayBack__AppendExample(HWND hWnd)
{
   L_INT nRet;
   // this will call the default constructor
   LBitmap LeadBitmap;
   L_TCHAR szFileName[256] ;
   lstrcpy(szFileName,MAKE_IMAGE_PATH(TEXT("eye.gif")));
   FILEINFO FileInfo;
   // create instance from User File
   LPBUserFile UserFile(hWnd, 0);
   // Attach a bitmap to the UserFile Object
   UserFile.SetBitmap (&LeadBitmap);
   // attach a file name to UserFile Object
   UserFile.SetFileName(szFileName);
   // get the info of the  file object
   nRet = UserFile.GetInfo (&FileInfo, sizeof(FileInfo));
   if(nRet != SUCCESS)
      return nRet;
   // create the bitmap
   nRet = LeadBitmap.Create(FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel, FileInfo.Order);
   if(nRet != SUCCESS)
      return nRet;
   // load the file
   nRet = UserFile.LoadFile();
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
}