KDcraw

kdcraw.h
1/*
2 SPDX-FileCopyrightText: 2006-2015 Gilles Caulier <caulier dot gilles at gmail dot com>
3 SPDX-FileCopyrightText: 2006-2013 Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
4 SPDX-FileCopyrightText: 2007-2008 Guillaume Castagnino <casta at xwing dot info>
5
6 SPDX-License-Identifier: GPL-2.0-or-later
7*/
8
9#ifndef KDCRAW_H
10#define KDCRAW_H
11
12// C++ includes
13
14#include <cmath>
15#include <memory>
16
17// Qt includes
18
19#include <QBuffer>
20#include <QString>
21#include <QObject>
22#include <QImage>
23
24// Local includes
25
26#include "libkdcraw_export.h"
27#include "rawdecodingsettings.h"
28#include "dcrawinfocontainer.h"
29
30/** @brief Main namespace of libKDcraw
31 */
32namespace KDcrawIface
33{
34
35/** The wrapper class.
36 */
37class LIBKDCRAW_EXPORT KDcraw : public QObject
38{
39 Q_OBJECT
40
41public:
42
43 /** Standard constructor.
44 */
45 KDcraw();
46
47 /** Standard destructor.
48 */
49 virtual ~KDcraw();
50
51public:
52
53 /** Return a string version of libkdcraw release
54 */
55 static QString version();
56
57 /** Get the preview of RAW picture as a QImage.
58 It tries loadEmbeddedPreview() first and if it fails, calls loadHalfPreview().
59 */
60 static bool loadRawPreview(QImage& image, const QString& path);
61
62 /** Get the preview of RAW picture as a QByteArray holding JPEG data.
63 It tries loadEmbeddedPreview() first and if it fails, calls loadHalfPreview().
64 */
65 static bool loadRawPreview(QByteArray& imgData, const QString& path);
66
67 /** Get the preview of RAW picture passed in QBuffer as a QByteArray holding JPEG data.
68 It tries loadEmbeddedPreview() first and if it fails, calls loadHalfPreview().
69 */
70 static bool loadRawPreview(QByteArray& imgData, const QBuffer& inBuffer);
71
72 /** Get the embedded JPEG preview image from RAW picture as a QByteArray which will include Exif Data.
73 This is fast and non cancelable. This method does not require a class instance to run.
74 */
75 static bool loadEmbeddedPreview(QByteArray& imgData, const QString& path);
76
77 /** Get the embedded JPEG preview image from RAW picture as a QImage. This is fast and non cancelable
78 This method does not require a class instance to run.
79 */
80 static bool loadEmbeddedPreview(QImage& image, const QString& path);
81
82 /** Get the embedded JPEG preview image from RAW image passed in QBuffer as a QByteArray which will include Exif Data.
83 This is fast and non cancelable. This method does not require a class instance to run.
84 */
85 static bool loadEmbeddedPreview(QByteArray& imgData, const QBuffer& inBuffer);
86
87 /** Get the half decoded RAW picture. This is slower than loadEmbeddedPreview() method
88 and non cancelable. This method does not require a class instance to run.
89 */
90 static bool loadHalfPreview(QImage& image, const QString& path);
91
92 /** Get the half decoded RAW picture as JPEG data in QByteArray. This is slower than loadEmbeddedPreview()
93 method and non cancelable. This method does not require a class instance to run.
94 */
95 static bool loadHalfPreview(QByteArray& imgData, const QString& path);
96
97 /** Get the half decoded RAW picture passed in QBuffer as JPEG data in QByteArray. This is slower than loadEmbeddedPreview()
98 method and non cancelable. This method does not require a class instance to run.
99 */
100 static bool loadHalfPreview(QByteArray& imgData, const QBuffer& inBuffer);
101
102 /** Get the full decoded RAW picture. This is a more slower than loadHalfPreview() method
103 and non cancelable. This method does not require a class instance to run.
104 */
105 static bool loadFullImage(QImage& image, const QString& path, const RawDecodingSettings& settings = RawDecodingSettings());
106
107 /** Get the camera settings witch have taken RAW file. Look into dcrawinfocontainer.h
108 for more details. This is a fast and non cancelable method witch do not require
109 a class instance to run.
110 */
111 static bool rawFileIdentify(DcrawInfoContainer& identify, const QString& path);
112
113 /** Return the string of all RAW file type mime supported.
114 */
115 static const char* rawFiles();
116
117 /** Return the list of all RAW file type mime supported,
118 as a QStringList, without wildcard and suffix dot.
119 */
120 static QStringList rawFilesList();
121
122 /** Returns a version number for the list of supported RAW file types.
123 This version is incremented if the list of supported formats has changed
124 between library releases.
125 */
126 static int rawFilesVersion();
127
128 /** Provide a list of supported RAW Camera name.
129 */
130 static QStringList supportedCamera();
131
132 /** Return LibRaw version string.
133 */
134 static QString librawVersion();
135
136 /** Return true or false if LibRaw use parallel demosaicing or not (libgomp support).
137 * Return -1 if undefined.
138 */
139 static int librawUseGomp();
140
141 /** Return true or false if LibRaw use RawSpeed codec or not.
142 * Return -1 if undefined.
143 */
144 static int librawUseRawSpeed();
145
146 /** Return true or false if LibRaw use Demosaic Pack GPL2 or not.
147 * Return -1 if undefined.
148 */
149 static int librawUseGPL2DemosaicPack();
150
151 /** Return true or false if LibRaw use Demosaic Pack GPL3 or not.
152 * Return -1 if undefined.
153 */
154 static int librawUseGPL3DemosaicPack();
155
156public:
157
158 /** Extract Raw image data undemosaiced and without post processing from 'filePath' picture file.
159 This is a cancelable method which require a class instance to run because RAW pictures loading
160 can take a while.
161
162 This method return:
163
164 - A byte array container 'rawData' with raw data.
165 - All info about Raw image into 'identify' container.
166 - 'false' is returned if loadding failed, else 'true'.
167 */
168 bool extractRAWData(const QString& filePath, QByteArray& rawData, DcrawInfoContainer& identify, unsigned int shotSelect=0);
169
170 /** Extract a small size of decode RAW data from 'filePath' picture file using
171 'rawDecodingSettings' settings. This is a cancelable method which require
172 a class instance to run because RAW pictures decoding can take a while.
173
174 This method return:
175
176 - A byte array container 'imageData' with picture data. Pixels order is RGB.
177 Color depth can be 8 or 16. In 8 bits you can access to color component
178 using (uchar*), in 16 bits using (ushort*).
179
180 - Size size of image in number of pixels ('width' and 'height').
181 - The max average of RGB components from decoded picture.
182 - 'false' is returned if decoding failed, else 'true'.
183 */
184 bool decodeHalfRAWImage(const QString& filePath, const RawDecodingSettings& rawDecodingSettings,
185 QByteArray& imageData, int& width, int& height, int& rgbmax);
186
187 /** Extract a full size of RAW data from 'filePath' picture file using
188 'rawDecodingSettings' settings. This is a cancelable method which require
189 a class instance to run because RAW pictures decoding can take a while.
190
191 This method return:
192
193 - A byte array container 'imageData' with picture data. Pixels order is RGB.
194 Color depth can be 8 or 16. In 8 bits you can access to color component
195 using (uchar*), in 16 bits using (ushort*).
196
197 - Size size of image in number of pixels ('width' and 'height').
198 - The max average of RGB components from decoded picture.
199 - 'false' is returned if decoding failed, else 'true'.
200 */
201 bool decodeRAWImage(const QString& filePath, const RawDecodingSettings& rawDecodingSettings,
202 QByteArray& imageData, int& width, int& height, int& rgbmax);
203
204 /** To cancel 'decodeHalfRAWImage' and 'decodeRAWImage' methods running
205 in a separate thread.
206 */
207 void cancel();
208
209protected:
210
211 /** Used internally to cancel RAW decoding operation. Normally, you don't need to use it
212 directly, excepted if you derivated this class. Usual way is to use cancel() method
213 */
215
216 /** The settings container used to perform RAW pictures decoding. See 'rawdecodingsetting.h'
217 for details.
218 */
220
221protected:
222
223 /** Re-implement this method to control the cancelisation of loop witch wait data
224 from RAW decoding process with your proper environment.
225 By default, this method check if m_cancel is true.
226 */
227 virtual bool checkToCancelWaitingData();
228
229 /** Re-implement this method to control the pseudo progress value during RAW decoding (when dcraw run with an
230 internal loop without feedback) with your proper environment. By default, this method does nothing.
231 Progress value average for this stage is 0%-n%, with 'n' == 40% max (see setWaitingDataProgress() method).
232 */
233 virtual void setWaitingDataProgress(double value);
234
235private:
236 std::unique_ptr<class KDcrawPrivate> const d;
237
238 friend class KDcrawPrivate;
239};
240
241} // namespace KDcrawIface
242
243#endif /* KDCRAW_H */
A container for RAW image information.
The wrapper class.
Definition kdcraw.h:38
RawDecodingSettings m_rawDecodingSettings
The settings container used to perform RAW pictures decoding.
Definition kdcraw.h:219
static bool loadRawPreview(QByteArray &imgData, const QBuffer &inBuffer)
Get the preview of RAW picture passed in QBuffer as a QByteArray holding JPEG data.
static bool loadRawPreview(QByteArray &imgData, const QString &path)
Get the preview of RAW picture as a QByteArray holding JPEG data.
bool m_cancel
Used internally to cancel RAW decoding operation.
Definition kdcraw.h:214
Main namespace of libKDcraw.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:56:21 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.