1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:48:11 +00:00

LibPDF: Implement the DCT filter

This filter basically tells us that we are dealing with a JPEG.
Note that by serializing the resulting image we assume that this filter
is the last one in the chain, everything else would be highly unlikely.
This commit is contained in:
Julian Offenhäuser 2022-10-27 20:19:08 +02:00 committed by Andreas Kling
parent baaf42360e
commit f926dfe36b

View file

@ -6,6 +6,7 @@
#include <AK/Hex.h>
#include <LibCompress/Deflate.h>
#include <LibGfx/JPGLoader.h>
#include <LibPDF/CommonNames.h>
#include <LibPDF/Filter.h>
@ -153,10 +154,11 @@ ErrorOr<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes)
TODO();
};
ErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes)
ErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes bytes)
{
// FIXME: Support dct decoding
TODO();
Gfx::JPGImageDecoderPlugin decoder(bytes.data(), bytes.size());
auto frame = TRY(decoder.frame(0));
return frame.image->serialize_to_byte_buffer();
};
ErrorOr<ByteBuffer> Filter::decode_jpx(ReadonlyBytes)