Skip to content

Commit d54dbda

Browse files
LucasCholletgmta
authored andcommitted
LibGfx/CCITT: Introduce the invert helper
This function turns Black into White and White into Black.
1 parent ce0ac70 commit d54dbda

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Userland/Libraries/LibGfx/ImageFormats/CCITTDecoder.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ Optional<Code> get_terminal_code(Color color, u16 code_word, u8 code_size)
267267
constexpr auto const ccitt_white = Color::NamedColor::White;
268268
constexpr auto const ccitt_black = Color::NamedColor::Black;
269269

270+
Color invert(Color current_color)
271+
{
272+
return current_color == ccitt_white ? ccitt_black : ccitt_white;
273+
}
274+
270275
ErrorOr<void> decode_single_ccitt3_1d_line(BigEndianInputBitStream& input_bit_stream, BigEndianOutputBitStream& decoded_bits, u32 image_width)
271276
{
272277
// We always flip the color when entering the loop, so let's initialize the
@@ -284,7 +289,7 @@ ErrorOr<void> decode_single_ccitt3_1d_line(BigEndianInputBitStream& input_bit_st
284289
continue;
285290
}
286291

287-
current_color = current_color == ccitt_white ? ccitt_black : ccitt_white;
292+
current_color = invert(current_color);
288293

289294
u8 size {};
290295
u16 potential_code {};

0 commit comments

Comments
 (0)