Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
LBitmapList::Create
#include "ltwrappr.h"
virtual L_INT LBitmapList::Create()
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:
calling LBitmapList::Create
calling the constructor LBitmapList(LBitmapList * pBitmapList)
using the = operator
using LBitmapList::Load
calling LBitmapList::CopyItems
calling LBitmapList::SetBitmapList
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: |
|
Topics: |
|
|
Example
L_INT LBitmapList__CreateExample(HWND hWnd, L_TCHAR * szFilename,LBitmapBase LeadBitmap) { UNREFERENCED_PARAMETER(szFilename); L_INT nRet; 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) { nRet =LeadBitmap.Resize(&LeadBitmap, sizeof(BITMAPHANDLE), SIZE_RESAMPLE); if(nRet !=SUCCESS) return nRet; } else if (LeadBitmap.GetHeight()>nMax) { nRet =LeadBitmap.Resize(&LeadBitmap, sizeof(BITMAPHANDLE), SIZE_RESAMPLE); if(nRet !=SUCCESS) return nRet; } /* Dither to an optimized palette, leaving the last color blank to use later for transparency */ nRet =LeadBitmap.ColorRes(8,CRF_FLOYDSTEINDITHERING|CRF_OPTIMIZEDPALETTE|CRF_IDENTITYPALETTE,NULL); if(nRet !=SUCCESS) return nRet; /* 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; nRet =LeadBitmap.PutColors(255,1,TmpPalette); if(nRet !=SUCCESS) return nRet; /* 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 */ nRet =BmpList.Create(); if(nRet !=SUCCESS) return nRet; for (i = 0; i <= 36; ++ i) { TmpBitmap=LeadBitmap; /* Rotate, using the transparent color as the fill color */ nRet =TmpBitmap.Rotate(1000*i,FALSE,PALETTEINDEX(255)); if(nRet !=SUCCESS) return nRet; nRet =BmpList.InsertItem(&TmpBitmap); if(nRet !=SUCCESS) return nRet; } /* 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 */ nRet =PlayBack.Create(&LeadBitmap,&BmpList); if(nRet !=SUCCESS) return nRet; 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 SUCCESS; }