1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:27:45 +00:00

LibGfx/CCITT: Don't be fooled by black-starting lines

The first marker is always white in CCITT streams, so lines starting
with a black pixel encodes a symbol meaning 0 white pixels. Then, the
decoding would proceed with a black symbol. We used to set the symbol's
color based on `column == 0`, which is wrong in this situation.
This commit is contained in:
Lucas CHOLLET 2024-02-11 23:14:44 -05:00 committed by Jelle Raaijmakers
parent a4b2e5b27b
commit f5e7ee8d4a

View file

@ -269,7 +269,9 @@ ErrorOr<void> decode_single_ccitt3_1d_line(BigEndianInputBitStream& input_bit_st
auto const ccitt_white = Color::NamedColor::White; auto const ccitt_white = Color::NamedColor::White;
auto const ccitt_black = Color::NamedColor::Black; auto const ccitt_black = Color::NamedColor::Black;
Color current_color { ccitt_white }; // We always flip the color when entering the loop, so let's initialize the
// color with black to make the first marker actually be white.
Color current_color { ccitt_black };
u32 run_length = 0; u32 run_length = 0;
u32 column = 0; u32 column = 0;
@ -284,10 +286,6 @@ ErrorOr<void> decode_single_ccitt3_1d_line(BigEndianInputBitStream& input_bit_st
current_color = current_color == ccitt_white ? ccitt_black : ccitt_white; current_color = current_color == ccitt_white ? ccitt_black : ccitt_white;
if (column == 0) {
current_color = ccitt_white;
}
u8 size {}; u8 size {};
u16 potential_code {}; u16 potential_code {};
while (size < 14) { while (size < 14) {