Skip to content

Instantly share code, notes, and snippets.

@HemulGM
Created August 16, 2022 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HemulGM/a9ea4b573b3fe9146cd7f7195e60cf93 to your computer and use it in GitHub Desktop.
Save HemulGM/a9ea4b573b3fe9146cd7f7195e60cf93 to your computer and use it in GitHub Desktop.
skia frames render
uses Skia, Skia.FMX;
procedure TForm3.FormCreate(Sender: TObject);
var
Buffer: TBitmap;
begin
var Lottie := TSkottieAnimation.MakeFromFile('D:\Downloads\3-8472.json');
Lottie.SeekFrameTime(0);
var Tick := Lottie.Duration / (Lottie.Duration * Lottie.FPS);
var i := Tick;
var n := 0;
Buffer := TBitmap.Create(Trunc(Lottie.Size.Width), Trunc(Lottie.Size.Height));
try
while i < Lottie.Duration do
begin
Buffer.SkiaDraw(
procedure(const ACanvas: ISkCanvas)
begin
Lottie.Render(ACanvas, TRectF.Create(0, 0, Lottie.Size.Width, Lottie.Size.Height));
end, True);
Inc(n);
i := i + Tick;
Buffer.SaveToFile('D:\Temp\Anim\' + n.ToString + '.png');
Lottie.SeekFrameTime(i);
end;
finally
Buffer.Free;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment