Some very small optimizations in CImgUtil.

This commit is contained in:
Leon Styhre 2021-11-09 22:57:15 +01:00
parent 3e12fcb420
commit 39926abc41
2 changed files with 8 additions and 8 deletions

View file

@ -12,7 +12,7 @@ namespace Utils
{
namespace CImg
{
void convertRGBAToCImg(std::vector<unsigned char> imageRGBA,
void convertRGBAToCImg(const std::vector<unsigned char>& imageRGBA,
cimg_library::CImg<unsigned char>& image)
{
// CImg does not interleave the pixels as in RGBARGBARGBA so a conversion is required.
@ -28,15 +28,15 @@ namespace Utils
}
}
void convertCImgToRGBA(cimg_library::CImg<unsigned char> image,
void convertCImgToRGBA(const cimg_library::CImg<unsigned char>& image,
std::vector<unsigned char>& imageRGBA)
{
for (int r = image.height() - 1; r >= 0; r--) {
for (int c = 0; c < image.width(); c++) {
imageRGBA.push_back((unsigned char)image(c, r, 0, 2));
imageRGBA.push_back((unsigned char)image(c, r, 0, 1));
imageRGBA.push_back((unsigned char)image(c, r, 0, 0));
imageRGBA.push_back((unsigned char)image(c, r, 0, 3));
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 2));
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 1));
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 0));
imageRGBA.emplace_back((unsigned char)image(c, r, 0, 3));
}
}
}

View file

@ -20,9 +20,9 @@ namespace Utils
{
namespace CImg
{
void convertRGBAToCImg(std::vector<unsigned char> imageRGBA,
void convertRGBAToCImg(const std::vector<unsigned char>& imageRGBA,
cimg_library::CImg<unsigned char>& image);
void convertCImgToRGBA(cimg_library::CImg<unsigned char> image,
void convertCImgToRGBA(const cimg_library::CImg<unsigned char>& image,
std::vector<unsigned char>& imageRGBA);
void getTransparentPaddingCoords(cimg_library::CImg<unsigned char>& image,
int (&imageCoords)[4]);