KItinerary

imagedocumentprocessor.cpp
1/*
2 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "imagedocumentprocessor.h"
8#include "barcodedocumentprocessorhelper.h"
9
10#include <KItinerary/BarcodeDecoder>
11#include <KItinerary/ExtractorDocumentNodeFactory>
12#include <KItinerary/ExtractorEngine>
13
14#include <QImage>
15
16using namespace KItinerary;
17
19{
20 const auto img = QImage::fromData(encodedData);
21 if (img.isNull()) {
22 return {};
23 }
24
26 node.setContent(img);
27 return node;
28}
29
31{
32 // skip barcode extraction if somebody else already did that (such as the PDF processor)
33 if (!node.childNodes().empty()) {
34 return;
35 }
36
37 const auto img = node.content<QImage>();
38
39 BarcodeDecoder::BarcodeTypes barcodeHints = BarcodeDecoder::Any2D | BarcodeDecoder::Any1D;
40 // check whether we possibly have a full PDF page raster image here
42 barcodeHints |= BarcodeDecoder::IgnoreAspectRatio;
43 }
44 barcodeHints = BarcodeDecoder::maybeBarcode(img.width(), img.height(), barcodeHints);
45
46 BarcodeDocumentProcessorHelper::expandNode(img, barcodeHints, node, engine);
47}
static BarcodeTypes maybeBarcode(int width, int height, BarcodeTypes hint)
The combination of the above.
A node in the extracted document object tree.
QJSValue content
The decoded content of this node.
QVariantList childNodes
Child nodes, for QJSEngine access.
void setContent(const QVariant &content)
Set decoded content.
Semantic data extraction engine.
@ ExtractFullPageRasterImages
perform expensive image processing on (PDF) documents containing full page raster images
Hints hints() const
The currently set extraction hints.
ExtractorDocumentNode createNodeFromData(const QByteArray &encodedData) const override
Create a document node from raw data.
void expandNode(ExtractorDocumentNode &node, const ExtractorEngine *engine) const override
Create child nodes for node, as far as that's necessary for this document type.
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
QImage fromData(QByteArrayView data, const char *format)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:28:48 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.