Skip to content

Commit

Permalink
LibPDF: In Filter::decode_jbig2(), invert bits
Browse files Browse the repository at this point in the history
See included comment.
  • Loading branch information
nico committed Mar 9, 2024
1 parent f54c9b3 commit 7594902
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Userland/Libraries/LibPDF/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,14 @@ PDFErrorOr<ByteBuffer> Filter::decode_jbig2(Document* document, ReadonlyBytes by
}

segments.append(bytes);
return TRY(Gfx::JBIG2ImageDecoderPlugin::decode_embedded(segments));
auto decoded = TRY(Gfx::JBIG2ImageDecoderPlugin::decode_embedded(segments));

// JBIG2 treats `1` as "ink present" (black) and `0` as "no ink" (white).
// PDF treats `1` as "light present" (white) and `1` as "no light" (black).
// So we have to invert.
invert_bits(decoded);

return decoded;
}

PDFErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes bytes)
Expand Down

0 comments on commit 7594902

Please sign in to comment.