Skip to content

Commit

Permalink
Fix one frame missing (#529)
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: #527
  • Loading branch information
mmaciola committed Sep 19, 2022
1 parent 30f300d commit 12facb8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lottie/lottieitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ VMatrix renderer::Layer::matrix(int frameNo) const
bool renderer::Layer::visible() const
{
return (frameNo() >= mLayerData->inFrame() &&
frameNo() < mLayerData->outFrame());
frameNo() <= mLayerData->outFrame());
}

void renderer::Layer::preprocess(const VRect &clip)
Expand Down
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
4 changes: 2 additions & 2 deletions src/lottie/lottieparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ void LottieParserImpl::parseComposition()
} else if (0 == strcmp(key, "h")) {
comp->mSize.setHeight(GetInt());
} else if (0 == strcmp(key, "ip")) {
comp->mStartFrame = GetDouble();
comp->mStartFrame = std::lround(GetDouble());
} else if (0 == strcmp(key, "op")) {
comp->mEndFrame = GetDouble();
comp->mEndFrame = std::lround(GetDouble());
} else if (0 == strcmp(key, "fr")) {
comp->mFrameRate = GetDouble();
} else if (0 == strcmp(key, "assets")) {
Expand Down

0 comments on commit 12facb8

Please sign in to comment.