L_CreateBitmapList

Summary

Creates an empty list of LEAD bitmaps. The list can then be built and maintained with related functions.

Syntax

#include "l_bitmap.h"

L_LTKRN_API L_INT L_CreateBitmapList(phList)

Parameters

pHBITMAPLIST phList

Address of the HBITMAPLIST variable for the new list.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example creates a bitmap list from the current bitmap, rotating each copy by 10 degrees.
It defines the rotation fill color as a transparent color, and assigns an animation background color.
It then plays the animation, using the current bitmap as the target.

L_INT CreateBitmapListExample(HWND          hWnd, 
                                              HPALETTE      hpalPaint,/* Paint palette handle. */ 
                                              pBITMAPHANDLE pBitmap)  /* Bitmap handle for the loaded image. */ 
{ 
   L_INT nRet; 
   HBITMAPLIST    hList;            /* Bitmap list */ 
   BITMAPHANDLE   TmpBitmap;        /* Temporary bitmap for building the list */ 
   L_INT          nMax = 160;       /* Maximum width or height for bitmaps in the list */ 
   HPLAYBACK      hPlayback;        /* Animation playback */ 
   L_UINT         uState;           /* Next state in the playback */ 
   RECT           rcUpdate;         /* Source clipping rectangle used in playback */ 
   RECT           rcDisplay;        /* Display rectangle used in playback */ 
   HDC            hdc;              /* Device context of the current window */ 
   HPALETTE       hPalette = NULL;  /* Temporary copy of the current system palette */ 
   RGBQUAD        TmpPalette[1];    /* Palette to define the transparent color */ 
   L_INT          i;                /* Loop counter */ 
 
   /* Reduce memory requirements, if necessary. Only small bitmaps play smoothly. */ 
   if (pBitmap->Width > nMax) 
   { 
      nRet = L_SizeBitmap (pBitmap, nMax, (pBitmap->Height * nMax) / pBitmap->Width, SIZE_RESAMPLE); 
      if(nRet !=SUCCESS) 
         return nRet; 
   } 
   else if (pBitmap->Height > nMax) 
   {      
      nRet = L_SizeBitmap (pBitmap, (pBitmap->Width * nMax) / pBitmap->Height, nMax, SIZE_RESAMPLE); 
      if(nRet !=SUCCESS) 
         return nRet; 
   } 
   /* Dither to an optimized palette, leaving the last color blank to use 
   later for transparency */ 
   nRet = L_ColorResBitmap(pBitmap, pBitmap, sizeof(BITMAPHANDLE), 8, CRF_FLOYDSTEINDITHERING|CRF_OPTIMIZEDPALETTE|CRF_IDENTITYPALETTE,  
                           NULL, NULL, 255, NULL, 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 = L_PutBitmapColors(pBitmap, 50, 1, TmpPalette); 
   if(nRet !=SUCCESS) 
      return nRet; 
   /* Create the paint palette */ 
   hdc = GetDC (hWnd); 
   hpalPaint = L_CreatePaintPalette (hdc, pBitmap); 
   ReleaseDC (hWnd, hdc); 
   /* Set the playback flags that will apply to all bitmaps in the list */ 
   pBitmap->Flags.WaitUserInput = FALSE; 
   pBitmap->Flags.Transparency = TRUE; 
   pBitmap->Left = 0; 
   pBitmap->Top = 0; 
   pBitmap->Delay = 10; 
   pBitmap->Transparency = PALETTEINDEX(255); /* Last color in the palette */ 
   pBitmap->DisposalMethod = PLAYDISPOSE_RESTOREBACKGROUND; 
   /* Create and populate the bitmap list */ 
   nRet = L_CreateBitmapList(&hList); 
   if(nRet !=SUCCESS) 
      return nRet; 
   for (i = 0; i <= 36; ++ i) 
   { 
      nRet = L_CopyBitmap(&TmpBitmap, pBitmap, sizeof(BITMAPHANDLE)); 
      if(nRet !=SUCCESS) 
         return nRet; 
      /* Rotate, using the transparent color as the fill color */ 
      nRet = L_RotateBitmap (&TmpBitmap, 1000 * i, 0, PALETTEINDEX(255)); 
      if(nRet !=SUCCESS) 
         return nRet; 
      nRet = L_InsertBitmapListItem(hList, (L_UINT)-1, &TmpBitmap); 
      if(nRet !=SUCCESS) 
         return nRet; 
   } 
   /* Set the background color for the animation playback */ 
   pBitmap->Background = RGB(0,0,255); 
   /* Use the client area as the display rectangle */ 
   GetClientRect(hWnd,&rcDisplay); 
   /* Create and run the playback */ 
   nRet = L_CreatePlayback(&hPlayback, pBitmap, hList); 
   if(nRet !=SUCCESS) 
      return nRet; 
   do 
   { 
      nRet = L_ProcessPlayback(hPlayback, &uState); 
      if(nRet !=SUCCESS) 
         return nRet; 
      switch(uState) 
      { 
      case PLAYSTATE_POSTRENDER: 
         nRet = L_GetPlaybackUpdateRect(hPlayback, &rcUpdate, TRUE); 
         if(nRet !=SUCCESS) 
            return nRet; 
         hdc = GetDC(hWnd); 
         if (hpalPaint) 
         { 
            hPalette = SelectPalette (hdc, hpalPaint, TRUE); 
            RealizePalette(hdc); 
         } 
         nRet = L_PaintDC (hdc, pBitmap, NULL, &rcUpdate, &rcDisplay, &rcDisplay, SRCCOPY); 
         if(nRet !=SUCCESS) 
            return nRet; 
         if (hpalPaint) 
            SelectPalette (hdc, hPalette, TRUE); 
         ReleaseDC(hWnd, hdc); 
         break; 
      } 
   } while(uState != PLAYSTATE_END); 
   /* Clean up */ 
   nRet = L_DestroyPlayback(hPlayback, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet = L_DestroyBitmapList(hList); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 

Help Version 22.0.2023.7.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 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.