Warning, file /libraries/ksanecore/src/imagebuilder.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * SPDX-FileCopyrightText: 2009 Kare Sars <kare dot sars at iki dot fi>
0003  * SPDX-FileCopyrightText: 2018 Alexander Volkov <a.volkov@rusbitech.ru>
0004  * SPDX-FileCopyrightText: 2021 Alexander Stippich <a.stippich@gmx.net>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0007  */
0008 
0009 #ifndef KSANE_IMAGE_BUILDER_H
0010 #define KSANE_IMAGE_BUILDER_H
0011 
0012 extern "C"
0013 {
0014 #include <sane/sane.h>
0015 }
0016 
0017 class QImage;
0018 
0019 namespace KSaneCore
0020 {
0021 
0022 /* Constructs a QImage out of the raw scanned data retrieved via libsane */
0023 class ImageBuilder
0024 {
0025 public:
0026     ImageBuilder(QImage *image, int *dpi);
0027 
0028     void start(const SANE_Parameters &params);
0029     void beginFrame(const SANE_Parameters &params);
0030     bool copyToImage(const SANE_Byte readData[], int read_bytes);
0031     void setDPI(int dpi);
0032     void cropImagetoSize();
0033 
0034 private:
0035     void renewImage();
0036     void incrementPixelData();
0037 
0038     SANE_Parameters m_params;
0039     int m_frameRead = 0;
0040     int m_pixelX = 0;
0041     int m_pixelY = 0;
0042     int m_pixelData[6];
0043     int m_pixelDataIndex = 0;
0044 
0045     QImage *m_image;
0046     int *m_dpi;
0047 };
0048 
0049 } // namespace KSaneCore
0050 
0051 #endif // KSANE_IMAGE_BUILDER_H