Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3 from prossel/master

fix getFrameIndexAtPercent() and optimize it for big numbers
  • Loading branch information...
commit 6a174fca8d270a238f3e574a35df6c79ccda58ac 2 parents f3bdef9 + 0b5819f
@obviousjim obviousjim authored
Showing with 3 additions and 4 deletions.
  1. +3 −4 src/ofxImageSequence.cpp
View
7 src/ofxImageSequence.cpp
@@ -204,10 +204,9 @@ ofTexture* ofxImageSequence::getFrameAtPercent(float percent)
int ofxImageSequence::getFrameIndexAtPercent(float percent)
{
- while (percent > 1.0) percent--;
- while (percent < 0.0) percent++;
+ 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)
@@ -281,6 +280,6 @@ int ofxImageSequence::imageTypeToGLType(int imageType)
return GL_RGBA;
default:
ofLog(OF_LOG_ERROR, "ofxImageSequence - unsupported image type for image");
- break;
+ return GL_RGB;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.