LPlayBack::Append

#include "ltwrappr.h"

virtual L_INT LPlayBack::Append(pLBitmap)

LBitmapBase L_FAR * 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.

See Also

Functions:

Class Members

Topics:

Raster Image Functions: Creating and Maintaining Lists of Images

 

Implementing Animation

Example

class LUserFile : public LFile
{
   HPALETTE m_hPalette;
   HWND m_hWnd;
   HDC m_hDC;
   RECT m_rcPaint;

public:
   LPlayBack m_PlayBack; // playback handle 

      LUserFile(HWND hwnd, LBitmapBase L_FAR *pBitmapBase);
      virtual ~LUserFile();
      virtual    L_INT  LoadFileCallBack(
                                                                pFILEINFO pFileInfo,
                                                               LBitmapBase L_FAR* pLBitmap,
                                                               LBuffer L_FAR* 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
//////////////////////////////////////////////////////////////////////
LUserFile::LUserFile(HWND hwnd, LBitmapBase L_FAR *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);

}

LUserFile::~LUserFile()
{
   ReleaseDC(m_hWnd, m_hDC);
}

L_INT  LUserFile::LoadFileCallBack(
                              pFILEINFO pFileInfo,
                              LBitmapBase L_FAR *pBitmap,
                              LBuffer L_FAR* pLBuffer,
                              L_UINT uFlags,
                              L_INT nRow,
                              L_INT nLines
                            )
{
   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 LUserFile::LoadFile(L_INT nBitsPerPixel,L_INT nOrder)
{
   m_PlayBack.Create (m_pBitmap);
   return LFile::LoadFile (nBitsPerPixel, nOrder, LOADFILE_ALLOCATE | LOADFILE_STORE | LOADFILE_ALLPAGES);
}


L_VOID PlayBackSamples(HWND hWnd)
{
   // this will call the default constructor
   LBitmap LeadBitmap;
   L_TCHAR szFileName[] = TEXT("d:\\ltwin14\\images\\image1.gif");
   FILEINFO FileInfo;

   // create instance from User File
   LUserFile 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
   UserFile.GetInfo (&FileInfo, sizeof(FileInfo));
   // create the bitmap
   LeadBitmap.Create(FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel, FileInfo.Order);
   // load the file
   UserFile.LoadFile();
}