Created
August 16, 2022 19:22
-
-
Save HemulGM/a9ea4b573b3fe9146cd7f7195e60cf93 to your computer and use it in GitHub Desktop.
skia frames render
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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