ColorResList example for C++ Builder
This example changes the hue of bitmaps in a list, then plays the list as an animation. When changing the hue, it preserves the transparent color.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i; /* Loop Counter */
int uCount; /* Number of bitmaps in the list */
long TransparentColor; /* Color used for transparency */
TransparentColor =Lead1->BitmapTransparentColor;
/* Avoid repaints while we modify the bitmaps. */
Lead1->AutoRepaint= False;
/* Change the hue of each bitmap in the list, */
/* and restore the transparent color as the last color in the palette. */
uCount = Lead1->BitmapListCount;
for(i = 0;i< (uCount - 1);i++)
{
Lead1->BitmapListIndex= i;
Lead1->Hue(i * 10);
Lead1->BitmapPalette[255] = TransparentColor;
}
/* Get an optimized palette for the whole list. */
Lead1->ColorResList(8, CRF_OPTIMIZEDPALETTE, CRF_NODITHERING, 0);
/* Update the palette that is used for playback. */
for i = 0; i <= 255; i++)
Lead1->AnimationPalette[i] = (TColor)Lead1->BitmapPalette[i];
/* Start the animation. */
Lead1->AutoRepaint= True;
Lead1->AnimationEnable= True;
}