1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:37:37 +00:00

LibPDF: Detect DCT images correctly

Images can have multiple filters, each one of them is processed
sequentially. Only the last one will be relevant for the image format
(DCT or JPXDecode), so use the last filter instead of the first one to
detect that property.
This commit is contained in:
Lucas CHOLLET 2023-11-11 23:35:26 -05:00 committed by Tim Flynn
parent f882a3ae37
commit 9e4d697d23

View file

@ -830,7 +830,8 @@ PDFErrorOr<NonnullRefPtr<Gfx::Bitmap>> Renderer::load_image(NonnullRefPtr<Stream
if (filter_object->is<NameObject>())
return filter_object->cast<NameObject>()->name() == name;
auto filters = filter_object->cast<ArrayObject>();
return MUST(filters->get_name_at(m_document, 0))->name() == name;
auto last_filter_index = filters->elements().size() - 1;
return MUST(filters->get_name_at(m_document, last_filter_index))->name() == name;
};
if (TRY(is_filter(CommonNames::JPXDecode))) {
return Error(Error::Type::RenderingUnsupported, "JPXDecode filter");