From f926dfe36b5eb21da90bcd6e0196728fe287decc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Offenh=C3=A4user?= Date: Thu, 27 Oct 2022 20:19:08 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibPDF/Filter.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPDF/Filter.cpp b/Userland/Libraries/LibPDF/Filter.cpp index 5d7da106b4..c184952be0 100644 --- a/Userland/Libraries/LibPDF/Filter.cpp +++ b/Userland/Libraries/LibPDF/Filter.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -153,10 +154,11 @@ ErrorOr Filter::decode_jbig2(ReadonlyBytes) TODO(); }; -ErrorOr Filter::decode_dct(ReadonlyBytes) +ErrorOr 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 Filter::decode_jpx(ReadonlyBytes)