Skip to content

Commit

Permalink
Fix one frame missing
Browse files Browse the repository at this point in the history
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: Samsung#527
  • Loading branch information
mmaciola committed Sep 14, 2022
1 parent 30f300d commit 1954f72
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lottie/lottiemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion src/lottie/lottieparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1954f72

Please sign in to comment.