LBitmapList::Create

#include "ltwrappr.h"

virtual L_INT LBitmapList::Create(L_VOID)

Creates a new bitmap list for the class object.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The class object must contain a valid bitmap list before you can use functions to insert, remove, or otherwise access bitmap list items.

You can create a bitmap list for the class object by doing one of the following:

image\sqrblit.gif calling LBitmapList::Create

image\sqrblit.gif calling the constructor LBitmapList(LBitmapList L_FAR* pBitmapList)

image\sqrblit.gif using the = operator

image\sqrblit.gif using LBitmapList::Load

image\sqrblit.gif calling LBitmapList::CopyItems

image\sqrblit.gif calling LBitmapList::SetBitmapList

image\sqrblit.gif calling LBitmapList::SetHandle.

Required DLLs and Libraries

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: Playing Animated Images

 

Implementing Animation

Example

LBitmapBase LeadBitmap;

void TestFunction(HWND hWnd, L_TCHAR L_FAR* szFilename)
{   
   LBitmapList  
BmpList; /* Bitmap list */
   LPlayBack    
PlayBack;
   LBitmapBase  
TmpBitmap; /* Temporary bitmap for building the list */
   LAnimationWindow 
Animation;
   L_INT nMax = 160; /* Maximum width or height for bitmaps in the list */
   HDC hdc; /* Device context of the current window */   
   RGBQUAD TmpPalette[1];  /* Palette to define the transparent color */
   L_INT i;                /* Loop counter */
   L_UINT uState;
   RECT rcUpdate,rcDisplay;
   HPALETTE hPalette, 
hpalPaint;

   /* Reduce memory requirements, if necessary. Only small bitmaps play smoothly. */
   if (LeadBitmap.GetWidth()>nMax)      
      LeadBitmap.
Resize(&LeadBitmap, sizeof(BITMAPHANDLE), SIZE_RESAMPLE);
   else 
      if (LeadBitmap.
GetHeight()>nMax)
          LeadBitmap.Resize(&LeadBitmap, sizeof(BITMAPHANDLE), SIZE_RESAMPLE);
   /* Dither to an optimized palette, leaving the last color blank to use   later for transparency */
   
LeadBitmap.
ColorRes(8,CRF_FLOYDSTEINDITHERING|CRF_OPTIMIZEDPALETTE|CRF_IDENTITYPALETTE,NULL);
   /* Set the transparent color in the last position of the palette */
   TmpPalette[0].rgbBlue = (BYTE) 202;
   TmpPalette[0].rgbGreen = (BYTE) 222;
   TmpPalette[0].rgbRed = (BYTE) 212;
   LeadBitmap.PutColors(255,1,TmpPalette);
   /* Create the paint palette */
   hdc = ::GetDC(hWnd);
   hpalPaint = LeadBitmap.
CreatePaintPalette(hdc);
   ::ReleaseDC(hWnd, hdc);

   /* Set the playback flags that will apply to all bitmaps in the list */
   LeadBitmap.
EnablePlayBackWaitUserInput(FALSE);
   LeadBitmap.
EnablePlayBackTransparency(TRUE);
   LeadBitmap.
SetPlayBackLeft(0);
   LeadBitmap.
SetPlayBackTop(0);
   LeadBitmap.
SetPlayBackDelay(10);
   LeadBitmap.
SetPlayBackTransparentColor(PALETTEINDEX(255));
   LeadBitmap.
SetPlayBackDisposalMethod(PLAYDISPOSE_RESTOREBACKGROUND);
   /* Create and populate the bitmap list */
   BmpList.
Create();
   for (i = 0; i <= 36; ++ i)
   {      
      TmpBitmap=LeadBitmap;
      /* Rotate, using the transparent color as the fill color */
      TmpBitmap.
Rotate(1000*i,FALSE,PALETTEINDEX(255));
      BmpList.
InsertItem(&TmpBitmap);
   }
   /* Set the background color for the animation playback */
   LeadBitmap.
SetPlayBackBackGroundColor(RGB(0,0,255));
   TmpBitmap=LeadBitmap;

   /* Use the client area as the display rectangle */
   ::GetClientRect(hWnd,&rcDisplay);
   /* Create and run the playback */
   PlayBack.Create(&LeadBitmap,&BmpList);
   do
   {
      uState=PlayBack.Process();
      switch(uState)
      {
      case PLAYSTATE_POSTRENDER:
         GetUpdateRect(hWnd, &rcUpdate,TRUE);
         hdc = ::GetDC(hWnd);
         if (hpalPaint)
         {
            hPalette = ::SelectPalette (hdc, hpalPaint, TRUE);
            ::RealizePalette(hdc);
         }
         PlayBack.
GetBitmap()->SetClipSrcRect(&rcUpdate);
         PlayBack.GetBitmap()->SetDstRect(&rcDisplay);
         PlayBack.GetBitmap()->SetClipDstRect(&rcDisplay);

         PlayBack.GetBitmap()->Paint()->SetDC(hdc);
         PlayBack.GetBitmap()->Paint()->PaintDC();
         if(hpalPaint)
            SelectPalette(hdc,hPalette,TRUE);
         ::ReleaseDC(hWnd, hdc);
         break;
      }
   } while(uState != PLAYSTATE_END);

   /* Clean up */
   PlayBack.
Destroy(0);
   LeadBitmap=TmpBitmap;
   return;
}