Update Texture.cpp
Some checks failed
Run ReCI Build Test / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
2025-02-02 21:21:33 -05:00
parent 7bc87d00ef
commit 26600915db

View File

@@ -28,6 +28,22 @@ invert_y(invert_y), filtering_mode(filtering_mode), wrapping_mode(wrapping_mode)
pixels = png(file);
ifStream.close();
if (invert_y) {
unsigned int row_size = size.x * 4;;
if (format == ColorFormat::RGB)
row_size = size.x * 3;
std::vector<unsigned char> temp(row_size);
for (unsigned int y = 0; y < size.y / 2; ++y) {
unsigned char *topRow = &pixels[y * row_size];
unsigned char *bottomRow = &pixels[(size.y - y - 1) * row_size];
std::copy(bottomRow, bottomRow + row_size, temp.begin());
std::copy(topRow, topRow + row_size, bottomRow);
std::copy(temp.begin(), temp.end(), topRow);
}
}
load(pixels.data());
}