1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-14 12:52:07 +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 <AK/Hex.h>
#include <LibCompress/Deflate.h> #include <LibCompress/Deflate.h>
#include <LibGfx/JPGLoader.h>
#include <LibPDF/CommonNames.h> #include <LibPDF/CommonNames.h>
#include <LibPDF/Filter.h> #include <LibPDF/Filter.h>
@ -153,10 +154,11 @@ ErrorOr<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes)
TODO(); TODO();
}; };
ErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes) ErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes bytes)
{ {
// FIXME: Support dct decoding Gfx::JPGImageDecoderPlugin decoder(bytes.data(), bytes.size());
TODO(); auto frame = TRY(decoder.frame(0));
return frame.image->serialize_to_byte_buffer();
}; };
ErrorOr<ByteBuffer> Filter::decode_jpx(ReadonlyBytes) ErrorOr<ByteBuffer> Filter::decode_jpx(ReadonlyBytes)