Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix getFrameIndexAtPercent() and optimize it for big numbers
remove a warning
  • Loading branch information
Pierre Rossel committed Jun 13, 2012
1 parent cb9e25a commit 67cf9a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ofxImageSequence.cpp
Expand Up @@ -182,10 +182,10 @@ ofTexture* ofxImageSequence::getFrameAtPercent(float percent)

int ofxImageSequence::getFrameIndexAtPercent(float percent)
{
while (percent > 1.0) percent--;
while (percent < 0.0) percent++;
// PR: fix and optimize for big numbers
if (percent < 0.0 || percent > 1.0) percent -= floor(percent);

return (int)MIN(percent*(sequence.size() - .5),sequence.size()-1);
return MIN((int)(percent*sequence.size()), sequence.size()-1);
}

ofTexture* ofxImageSequence::getFrameForTime(float time)
Expand Down Expand Up @@ -259,6 +259,6 @@ int ofxImageSequence::imageTypeToGLType(int imageType)
return GL_RGBA;
default:
ofLog(OF_LOG_ERROR, "ofxImageSequence - unsupported image type for image");
break;
return GL_RGB;
}
}

0 comments on commit 67cf9a5

Please sign in to comment.