ColorResList Example for C++ Builder

This example changes the hue of bitmaps in a list, and then plays the list as an animation. When changing the hue, it preserves the transparent color.

   short i;   // Loop counter
   int nCount; // Number of bitmaps in the list
   long int TransparentColor; // Color used for transparency
   LEADRasterProcess* pRasterProc= NULL;

     CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);

   // Save the current transparent color
   TransparentColor = LEADRasterView1->Raster->BitmapTransparentColor;
   // Avoid repaints while we modify the bitmaps
   LEADRasterView1->AutoRepaint = False;
   // Change the hue of each bitmap in the list,
   // and restore the transparent color as the last color in the palette
   nCount = LEADRasterView1->Raster->BitmapListCount;
   for (i = 0; i< nCount; i ++)
   {
       LEADRasterView1->Raster->BitmapListIndex = i;
       pRasterProc->Hue (LEADRasterView1->Raster, (short)(i * 10));
       LEADRasterView1->Raster->set_BitmapPalette (255, TransparentColor);
   }
   // Get an optimized palette for the whole list
   pRasterProc->ColorResList (LEADRasterView1->Raster, 8, CRP_OPTIMIZEDPALETTE, CRD_NODITHERING, 0);
   // Update the palette that is used for playback
   for (i = 0; i < 256; i++)
       LEADRasterView1->AnimationPalette [i] = LEADRasterView1->Raster->get_BitmapPalette(i);
   // Start the animation
   LEADRasterView1->AutoRepaint = True;
   LEADRasterView1->AnimationEnable = True;
   pRasterProc-> Release( );