mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
LibGfx/ILBMLoader: Don't decode bits once full row has been decoded
We were potentially decoding more bits than needed: this could trash the next lines if decoder didn't zero the extra bits.
This commit is contained in:
parent
d545fb2b60
commit
a1255cb6c9
|
@ -254,6 +254,17 @@ TEST_CASE(test_brush_transparent_color)
|
||||||
EXPECT_EQ(frame.image->get_pixel(114, 103), Gfx::Color::NamedColor::Black);
|
EXPECT_EQ(frame.image->get_pixel(114, 103), Gfx::Color::NamedColor::Black);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE(test_small_24bit)
|
||||||
|
{
|
||||||
|
auto file = MUST(Core::MappedFile::map(TEST_INPUT("ilbm/small-24bit.iff"sv)));
|
||||||
|
EXPECT(Gfx::ILBMImageDecoderPlugin::sniff(file->bytes()));
|
||||||
|
auto plugin_decoder = TRY_OR_FAIL(Gfx::ILBMImageDecoderPlugin::create(file->bytes()));
|
||||||
|
|
||||||
|
auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 10, 10 }));
|
||||||
|
|
||||||
|
EXPECT_EQ(frame.image->get_pixel(0, 4), Gfx::Color(1, 0, 1, 255));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE(test_ilbm_malformed_header)
|
TEST_CASE(test_ilbm_malformed_header)
|
||||||
{
|
{
|
||||||
Array test_inputs = {
|
Array test_inputs = {
|
||||||
|
|
BIN
Tests/LibGfx/test-inputs/ilbm/small-24bit.iff
Normal file
BIN
Tests/LibGfx/test-inputs/ilbm/small-24bit.iff
Normal file
Binary file not shown.
|
@ -220,7 +220,9 @@ static ErrorOr<ByteBuffer> planar_to_chunky(ReadonlyBytes bitplanes, ILBMLoading
|
||||||
u8 bit = bitplanes[offset_base + i];
|
u8 bit = bitplanes[offset_base + i];
|
||||||
u8 rgb_shift = p / 8;
|
u8 rgb_shift = p / 8;
|
||||||
|
|
||||||
for (u8 b = 0; b < 8; b++) {
|
// Some encoders don't pad bytes rows with 0: make sure we stop
|
||||||
|
// when enough data for current bitplane row has been read
|
||||||
|
for (u8 b = 0; b < 8 && (i * 8) + b < width; b++) {
|
||||||
u8 mask = 1 << (7 - b);
|
u8 mask = 1 << (7 - b);
|
||||||
// get current plane
|
// get current plane
|
||||||
if (bit & mask) {
|
if (bit & mask) {
|
||||||
|
|
Loading…
Reference in a new issue