ColorResList Example for Delphi
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.
var
i: integer; // Loop counter
uCount: Cardinal; // Number of bitmaps in the list
TransparentColor: Longint; // Color used for transparency
RasterProc: LEADRasterProcess;
begin
RasterProc:= CreateComObject (CLASS_LEADRasterProcess ) as LEADRasterProcess;
// 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.
uCount := LEADRasterView1.Raster.BitmapListCount;
for i := 0 to uCount - 1 do
begin
LEADRasterView1.Raster.BitmapListIndex:= i;
RasterProc.Hue (LEADRasterView1.Raster, i * 10);
LEADRasterView1.Raster.BitmapPalette [255]:= TransparentColor;
end;
// Get an optimized palette for the whole list.
RasterProc.ColorResList (LEADRasterView1.Raster, 8, CRP_OPTIMIZEDPALETTE, CRD_NODITHERING, 0);
// Update the palette that is used for playback.
for i := 0 to 255 do
LEADRasterView1.AnimationPalette [i] := LEADRasterView1.Raster.BitmapPalette[i];
// Start the animation.
LEADRasterView1.AutoRepaint:= True;
LEADRasterView1.AnimationEnable := True;
end;