Commit 9fbe9832 authored by Volker Krause's avatar Volker Krause
Browse files

Add support for compressed images outside of PDF files

This works for anything QImage supports, although only PNG is registered
so far, as that's practically the only format in use for barcodes.

This is mainly needed for porting KItinerary Workbench for now (which did
this handle this case manually so far), but we'll need that for supporting
images in HTML emails anyway.
parent 45244ec5
Pipeline #56214 passed with stages
in 13 minutes and 2 seconds
...@@ -112,7 +112,7 @@ void ExtractorDocumentNodeFactoryStatic::registerBuiltIn() ...@@ -112,7 +112,7 @@ void ExtractorDocumentNodeFactoryStatic::registerBuiltIn()
registerProcessor<PdfDocumentProcessor>(u"application/pdf"); registerProcessor<PdfDocumentProcessor>(u"application/pdf");
registerProcessor<PkPassDocumentProcessor>(u"application/vnd.apple.pkpass"); registerProcessor<PkPassDocumentProcessor>(u"application/vnd.apple.pkpass");
registerProcessor<IcalEventProcessor>(u"internal/event"); registerProcessor<IcalEventProcessor>(u"internal/event");
registerProcessor<ImageDocumentProcessor>(u"internal/qimage"); registerProcessor<ImageDocumentProcessor>(u"internal/qimage", {u"image/png"});
registerProcessor<Uic9183DocumentProcessor>(u"internal/uic9183"); registerProcessor<Uic9183DocumentProcessor>(u"internal/uic9183");
registerProcessor<VdvDocumentProcessor>(u"internal/vdv"); registerProcessor<VdvDocumentProcessor>(u"internal/vdv");
registerProcessor<IcalCalendarProcessor>(u"text/calendar"); registerProcessor<IcalCalendarProcessor>(u"text/calendar");
......
...@@ -14,6 +14,18 @@ ...@@ -14,6 +14,18 @@
using namespace KItinerary; using namespace KItinerary;
ExtractorDocumentNode ImageDocumentProcessor::createNodeFromData(const QByteArray &encodedData) const
{
const auto img = QImage::fromData(encodedData);
if (img.isNull()) {
return {};
}
ExtractorDocumentNode node;
node.setContent(img);
return node;
}
void ImageDocumentProcessor::expandNode(ExtractorDocumentNode &node, const ExtractorEngine *engine) const void ImageDocumentProcessor::expandNode(ExtractorDocumentNode &node, const ExtractorEngine *engine) const
{ {
// in case the barcode raw data (string or bytearray) gets detected as a type we handle, // in case the barcode raw data (string or bytearray) gets detected as a type we handle,
......
...@@ -14,6 +14,7 @@ namespace KItinerary { ...@@ -14,6 +14,7 @@ namespace KItinerary {
class ImageDocumentProcessor : public ExtractorDocumentProcessor class ImageDocumentProcessor : public ExtractorDocumentProcessor
{ {
public: public:
ExtractorDocumentNode createNodeFromData(const QByteArray &encodedData) const override;
void expandNode(ExtractorDocumentNode &node, const ExtractorEngine *engine) const override; void expandNode(ExtractorDocumentNode &node, const ExtractorEngine *engine) const override;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment