Changeset View
Changeset View
Standalone View
Standalone View
src/ksanescanthread.h
Context not available. | |||||
38 | 38 | | |||
---|---|---|---|---|---|
39 | #include <QThread> | 39 | #include <QThread> | ||
40 | #include <QByteArray> | 40 | #include <QByteArray> | ||
41 | #include <QMutex> | ||||
42 | #include <QImage> | ||||
43 | | ||||
44 | #include "ksanepreviewimagebuilder.h" | ||||
41 | 45 | | |||
42 | #define SCAN_READ_CHUNK_SIZE 100000 | 46 | #define SCAN_READ_CHUNK_SIZE 100000 | ||
43 | 47 | | |||
Context not available. | |||||
54 | READ_READY | 58 | READ_READY | ||
55 | } ReadStatus; | 59 | } ReadStatus; | ||
56 | 60 | | |||
57 | KSaneScanThread(SANE_Handle handle, QByteArray *data); | 61 | KSaneScanThread(SANE_Handle handle, QByteArray *data, QImage *img = nullptr); | ||
58 | void run() override; | 62 | void run() override; | ||
59 | void setImageInverted(bool); | 63 | void setImageInverted(bool); | ||
60 | void cancelScan(); | 64 | void cancelScan(); | ||
61 | int scanProgress(); | 65 | int scanProgress(); | ||
62 | bool saneStartDone(); | 66 | bool saneStartDone(); | ||
63 | 67 | | |||
68 | // used by KSaneWidget to check if reading of a new chunk changed QImage size | ||||
69 | // has sense only if setDisplayLastScan set to true | ||||
70 | bool imageResized(); | ||||
71 | | ||||
72 | // inform QThread that data should be displayed in QImage as well as returned as raw data. | ||||
73 | void setDisplayLastScan(bool); | ||||
74 | | ||||
64 | ReadStatus frameStatus(); | 75 | ReadStatus frameStatus(); | ||
65 | SANE_Status saneStatus(); | 76 | SANE_Status saneStatus(); | ||
66 | SANE_Parameters saneParameters(); | 77 | SANE_Parameters saneParameters(); | ||
67 | 78 | | |||
79 | QMutex imgMutex; | ||||
80 | | ||||
68 | private: | 81 | private: | ||
69 | void readData(); | 82 | void readData(); | ||
70 | void copyToScanData(int readBytes); | 83 | void copyToScanData(int readBytes); | ||
Context not available. | |||||
81 | ReadStatus m_readStatus; | 94 | ReadStatus m_readStatus; | ||
82 | bool m_saneStartDone; | 95 | bool m_saneStartDone; | ||
83 | bool m_invertColors; | 96 | bool m_invertColors; | ||
97 | // has sense only if setDisplayLastScan is set to true | ||||
98 | // required to prepare optional QImage with scan result | ||||
99 | std::unique_ptr<KSanePreviewImageBuilder> m_imageBuilder; | ||||
100 | bool m_displayLastScan; | ||||
84 | }; | 101 | }; | ||
85 | } | 102 | } | ||
86 | 103 | | |||
Context not available. |