mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:17:34 +00:00
LibCompress: Add a PackBits decoder
This compression scheme was quite popular during the 80's, and we can still find it in use inside file formats such as TIFF or PDF.
This commit is contained in:
parent
5d0fb4bac3
commit
d748edd994
5 changed files with 99 additions and 0 deletions
25
Tests/LibCompress/TestPackBits.cpp
Normal file
25
Tests/LibCompress/TestPackBits.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Lucas Chollet <lucas.chollet@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibTest/TestCase.h>
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <LibCompress/PackBitsDecoder.h>
|
||||
|
||||
TEST_CASE(pack_bits)
|
||||
{
|
||||
Array<u8, 15> const compressed {
|
||||
0xFE, 0xAA, 0x02, 0x80, 0x00, 0x2A, 0xFD, 0xAA, 0x03, 0x80, 0x00, 0x2A, 0x22, 0xF7, 0xAA
|
||||
};
|
||||
|
||||
Array<u8, 24> const raw {
|
||||
0xAA, 0xAA, 0xAA, 0x80, 0x00, 0x2A, 0xAA, 0xAA, 0xAA, 0xAA, 0x80, 0x00,
|
||||
0x2A, 0x22, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA
|
||||
};
|
||||
|
||||
auto unpacked = TRY_OR_FAIL(Compress::PackBits::decode_all(compressed));
|
||||
EXPECT_EQ(unpacked.bytes(), raw);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue