ColorResList example for Delphi

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.

var
  i: Integer; { Loop Counter }
  uCount: Integer;  { Number of bitmaps in the list }
  TransparentColor: LongInt;  { Color used for transparency }
begin
  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 to uCount - 1 do
   begin
     Lead1.BitmapListIndex:= i;
     Lead1.Hue(i * 10);
     Lead1.BitmapPalette[255] := TransparentColor;
   end; 
  { 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 to 255 do
     Lead1.AnimationPalette[i] := Lead1.BitmapPalette[i]; 
  { Start the animation. }
  Lead1.AutoRepaint := True;
  Lead1.AnimationEnable := True;
end;