1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:07:34 +00:00

LibGfx/TIFF: Correctly upscale samples with a resolution lower than 8

As pointed out by @nico, while doing a right-shift to downscale is fine,
a left-shift to upscale gives wrong results. As an example, imagine a 2-
bits value containing 3, left-shifting it would give 192 instead of 255.
This commit is contained in:
Lucas CHOLLET 2023-12-16 23:28:29 -05:00 committed by Andreas Kling
parent fc9a8c77d5
commit 7266d8c35d

View file

@ -83,7 +83,7 @@ private:
if (bits > 8)
return value >> (bits - 8);
return value << (8 - bits);
return NumericLimits<u8>::max() * value / ((1 << bits) - 1);
}
ErrorOr<Color> read_color(BigEndianInputBitStream& stream)