mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
LibGfx/TIFF+CCITT: Clarify naming of compression type 2
Type 2 <=> One-dimensional Group3, customized for TIFF Type 3 <=> Two-dimensional Group3, uses the original 1D internally Type 4 <=> Two-dimensional Group4 So let's clarify that this is not Group3 1D but the TIFF variant, which is called `CCITTRLE` in libtiff. So let's stick with this name to avoid confusion.
This commit is contained in:
parent
9b50b5793b
commit
edffdc35a9
6 changed files with 9 additions and 9 deletions
|
@ -543,9 +543,9 @@ TEST_CASE(test_tiff_uncompressed)
|
||||||
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Red);
|
EXPECT_EQ(frame.image->get_pixel(60, 75), Gfx::Color::NamedColor::Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(test_tiff_ccitt3_1d)
|
TEST_CASE(test_tiff_ccitt_rle)
|
||||||
{
|
{
|
||||||
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/ccitt3_1d.tiff"sv)));
|
auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("tiff/ccitt_rle.tiff"sv)));
|
||||||
EXPECT(Gfx::TIFFImageDecoderPlugin::sniff(file->bytes()));
|
EXPECT(Gfx::TIFFImageDecoderPlugin::sniff(file->bytes()));
|
||||||
auto plugin_decoder = TRY_OR_FAIL(Gfx::TIFFImageDecoderPlugin::create(file->bytes()));
|
auto plugin_decoder = TRY_OR_FAIL(Gfx::TIFFImageDecoderPlugin::create(file->bytes()));
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,7 @@ Optional<Code> get_terminal_code(Color color, u16 code_word, u8 code_size)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<ByteBuffer> decode_ccitt3_1d(ReadonlyBytes bytes, u32 image_width, u32 image_height)
|
ErrorOr<ByteBuffer> decode_ccitt_rle(ReadonlyBytes bytes, u32 image_width, u32 image_height)
|
||||||
{
|
{
|
||||||
auto strip_stream = make<FixedMemoryStream>(bytes);
|
auto strip_stream = make<FixedMemoryStream>(bytes);
|
||||||
auto bit_stream = make<BigEndianInputBitStream>(MaybeOwned<Stream>(*strip_stream));
|
auto bit_stream = make<BigEndianInputBitStream>(MaybeOwned<Stream>(*strip_stream));
|
||||||
|
|
|
@ -21,6 +21,6 @@ namespace Gfx::CCITT {
|
||||||
// However, this function implements the TIFF variant (see TIFFLoader.h for a spec link),
|
// However, this function implements the TIFF variant (see TIFFLoader.h for a spec link),
|
||||||
// differences are detailed in section:
|
// differences are detailed in section:
|
||||||
// Section 10: Modified Huffman Compression
|
// Section 10: Modified Huffman Compression
|
||||||
ErrorOr<ByteBuffer> decode_ccitt3_1d(ReadonlyBytes bytes, u32 image_width, u32 image_height);
|
ErrorOr<ByteBuffer> decode_ccitt_rle(ReadonlyBytes bytes, u32 image_width, u32 image_height);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,17 +281,17 @@ private:
|
||||||
TRY(loop_over_pixels(move(identity)));
|
TRY(loop_over_pixels(move(identity)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Compression::CCITT: {
|
case Compression::CCITTRLE: {
|
||||||
TRY(ensure_tags_are_correct_for_ccitt());
|
TRY(ensure_tags_are_correct_for_ccitt());
|
||||||
|
|
||||||
ByteBuffer decoded_bytes {};
|
ByteBuffer decoded_bytes {};
|
||||||
auto decode_ccitt_1D_strip = [&](u32 num_bytes) -> ErrorOr<ReadonlyBytes> {
|
auto decode_ccitt_rle_strip = [&](u32 num_bytes) -> ErrorOr<ReadonlyBytes> {
|
||||||
auto const encoded_bytes = TRY(m_stream->read_in_place<u8 const>(num_bytes));
|
auto const encoded_bytes = TRY(m_stream->read_in_place<u8 const>(num_bytes));
|
||||||
decoded_bytes = TRY(CCITT::decode_ccitt3_1d(encoded_bytes, *m_metadata.image_width(), *m_metadata.rows_per_strip()));
|
decoded_bytes = TRY(CCITT::decode_ccitt_rle(encoded_bytes, *m_metadata.image_width(), *m_metadata.rows_per_strip()));
|
||||||
return decoded_bytes;
|
return decoded_bytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
TRY(loop_over_pixels(move(decode_ccitt_1D_strip)));
|
TRY(loop_over_pixels(move(decode_ccitt_rle_strip)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Compression::LZW: {
|
case Compression::LZW: {
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Predictor(EnumWithExportName):
|
||||||
|
|
||||||
class Compression(EnumWithExportName):
|
class Compression(EnumWithExportName):
|
||||||
NoCompression = 1
|
NoCompression = 1
|
||||||
CCITT = 2
|
CCITTRLE = 2
|
||||||
Group3Fax = 3
|
Group3Fax = 3
|
||||||
Group4Fax = 4
|
Group4Fax = 4
|
||||||
LZW = 5
|
LZW = 5
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue