From 1954f7262165278b92eee19b5f271045bfe07f64 Mon Sep 17 00:00:00 2001 From: Michal Maciola Date: Wed, 14 Sep 2022 12:07:04 +0200 Subject: [PATCH] Fix one frame missing As mStartFrame and mEndFrame was counted from 0 and totalFrame() was calculated as a difference, there were always one frame missing and the animation rescaled. This patch adds one to the total frames count. issue: #527 --- src/lottie/lottiemodel.h | 4 ++-- src/lottie/lottieparser.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lottie/lottiemodel.h b/src/lottie/lottiemodel.h index 3e043085..745571e2 100644 --- a/src/lottie/lottiemodel.h +++ b/src/lottie/lottiemodel.h @@ -539,8 +539,8 @@ class Composition : public Object { { return long(frameAtPos(timeInSec / duration())); } - size_t totalFrame() const { return mEndFrame - mStartFrame; } - long frameDuration() const { return mEndFrame - mStartFrame - 1; } + size_t totalFrame() const { return mEndFrame - mStartFrame + 1; } + long frameDuration() const { return mEndFrame - mStartFrame; } float frameRate() const { return mFrameRate; } size_t startFrame() const { return mStartFrame; } size_t endFrame() const { return mEndFrame; } diff --git a/src/lottie/lottieparser.cpp b/src/lottie/lottieparser.cpp index 83be17e3..961e3d4c 100644 --- a/src/lottie/lottieparser.cpp +++ b/src/lottie/lottieparser.cpp @@ -699,7 +699,7 @@ void LottieParserImpl::parseComposition() resolveLayerRefs(); comp->setStatic(comp->mRootLayer->isStatic()); comp->mRootLayer->mInFrame = comp->mStartFrame; - comp->mRootLayer->mOutFrame = comp->mEndFrame; + comp->mRootLayer->mOutFrame = comp->mEndFrame + 1; mComposition = sharedComposition; }