Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix getFrameIndexAtPercent() and optimize it for big numbers

remove a warning
  • Loading branch information...
commit 67cf9a52dfd4a79f74b94593a6fdb1223f9a8ba7 1 parent cb9e25a
Pierre Rossel authored
Showing with 4 additions and 4 deletions.
  1. +4 −4 src/ofxImageSequence.cpp
View
8 src/ofxImageSequence.cpp
@@ -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)
@@ -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;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.