Skip to content

Commit

Permalink
Speed up image loading (#6035)
Browse files Browse the repository at this point in the history
Currently ofLoadImage spends a large percentage of its time on ofToDataPath when loading lots of small images from disk. These changes help speed this up when absolute paths are already known.
  • Loading branch information
bakercp authored and arturoc committed Aug 12, 2018
1 parent e8ad683 commit 4b03c10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/openFrameworks/graphics/ofImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static bool loadImage(ofPixels_<PixelType> & pix, const std::filesystem::path& _
return ofLoadImage(pix, ofLoadURL(_fileName.string()).data);
}

std::string fileName = ofToDataPath(_fileName);
std::string fileName = ofToDataPath(_fileName, true);
bool bLoaded = false;
FIBITMAP * bmp = nullptr;

Expand Down
3 changes: 3 additions & 0 deletions libs/openFrameworks/utils/ofUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ void ofSetDataPathRoot(const std::filesystem::path& newRoot){

//--------------------------------------------------
string ofToDataPath(const std::filesystem::path & path, bool makeAbsolute){
if (makeAbsolute && path.is_absolute())
return path.string();

if (!enableDataPath)
return path.string();

Expand Down

0 comments on commit 4b03c10

Please sign in to comment.