-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#ifndef THREEPP_IMAGEUTILS_HPP | ||
#define THREEPP_IMAGEUTILS_HPP | ||
|
||
#include <vector> | ||
#include <algorithm> | ||
|
||
namespace threepp { | ||
|
||
inline void convertBGRtoRGB(std::vector<unsigned char>& pixels) { | ||
for (size_t i = 0; i < pixels.size(); i += 3) { | ||
std::swap(pixels[i], pixels[i + 2]); | ||
} | ||
} | ||
|
||
inline void flipImage(std::vector<unsigned char>& pixels, int channels, int w, int h) { | ||
for (int line = 0; line != h / 2; ++line) { | ||
std::swap_ranges(pixels.begin() + channels * w * line, | ||
pixels.begin() + channels * w * (line + 1), | ||
pixels.begin() + channels * w * (h - line - 1)); | ||
} | ||
} | ||
|
||
}// namespace threepp | ||
|
||
#endif //THREEPP_IMAGEUTILS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters