Search code examples
delphifiremonkey

Change color of TAniIndicator


In Delphi 10.2 Tokyo I use a TAniIndicator until the database is loaded.

By default, the color of the bubble is black. I would like to change it to be white without creating a Style. I haven't found any property for that.

Is there any way to change it?


Solution

  • You can do something like this (for default style), note that you'll need to improve ReplaceBlackColor function to make bubble completely white

    procedure ReplaceBlackColor(const ABitmap: TBitmap);
    var
      I, J: Integer;
      M: TBitmapData;
      C: PAlphaColorRec;
    begin
      if ABitmap.Map(TMapAccess.ReadWrite, M) then
      try
        for J := 0 to ABitmap.Height - 1 do
          for I := 0 to ABitmap.Width - 1 do
          begin
            C := @PAlphaColorArray(M.Data)[J * (M.Pitch div 4) + I];
            if C^.Color = TAlphaColorRec.Black then
              C^.Color := TAlphaColorRec.White;
          end;
      finally
        ABitmap.Unmap(M);
      end;
    end;
    
    procedure TForm3.Button1Click(Sender: TObject);
    var
      bla: TBitmapListAnimation;
    begin
      bla := AniIndicator1.FindStyleResource('ani') as TBitmapListAnimation;
      ReplaceBlackColor(bla.AnimationBitmap);
    end;