Fix colorizing sparse images.

This commit is contained in:
John Preston 2022-03-18 20:40:27 +04:00
parent af680714ff
commit 1027fb5dff

View file

@ -1131,7 +1131,10 @@ QImage Colored(QImage &&image, QColor add) {
const auto w = image.width();
const auto h = image.height();
const auto size = w * h * 4;
for (auto i = index_type(); i != size; i += 4) {
const auto add = image.bytesPerLine() - (w * 4);
auto i = index_type();
for (auto y = 0; y != h; ++y) {
for (auto to = i + (w * 4); i != to; i += 4) {
const auto b = pix[i];
const auto g = pix[i + 1];
const auto r = pix[i + 2];
@ -1142,6 +1145,8 @@ QImage Colored(QImage &&image, QColor add) {
pix[i + 2] = uchar(r + ((aca * (cr - r)) >> 16));
pix[i + 3] = uchar(a + ((aca * (0xFF - a)) >> 16));
}
i += add;
}
}
return std::move(image);
}