1
/* ============================================================
3
* This file is a part of kipi-plugins project
4
* http://www.kipi-plugins.org
7
* Description : a tread-safe dcraw program interface
9
* Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
10
* Copyright (C) 2006-2008 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11
* Copyright (C) 2007-2008 by Guillaume Castagnino <casta at xwing dot info>
13
* This program is free software; you can redistribute it
14
* and/or modify it under the terms of the GNU General
15
* Public License as published by the Free Software Foundation;
16
* either version 2, or (at your option) any later version.
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
23
* ============================================================ */
36
#include "libkdcraw_export.h"
37
#include "rawdecodingsettings.h"
38
#include "dcrawinfocontainer.h"
49
class LIBKDCRAW_EXPORT KDcraw : public QObject
55
/** Standard constructor. */
58
/** Standard destructor. */
63
/** Return a string version of libkdcraw release */
64
static QString version();
66
/** This is a non cancelable method witch do not require a class instance to run.
67
It can loadEmbeddedPreview() in first and if it failed, call loadHalfPreview().
69
static bool loadDcrawPreview(QImage& image, const QString& path);
71
/** Get the embedded JPEG preview image from RAW picture. This is a fast and non cancelable
72
This method do not require a class instance to run.
74
static bool loadEmbeddedPreview(QImage& image, const QString& path);
76
/** Get the half decode RAW picture. This is a more slower than loadEmbeddedPreview() method
77
and non cancelable. This method do not require a class instance to run.
79
static bool loadHalfPreview(QImage& image, const QString& path);
81
/** Get the camera settings witch have taken RAW file. Look into dcrawinfocontainer.h
82
for more details. This is a fast and non cancelable method witch do not require
83
a class instance to run.
85
static bool rawFileIdentify(DcrawInfoContainer& identify, const QString& path);
89
/** Extract a small size of decode RAW data from 'filePath' picture file using
90
'rawDecodingSettings' settings. This is a cancelable method witch require
91
a class instance to run because RAW pictures decoding can take a while.
95
- A byte array container ('imageData') with picture data. Pixels order is RGB.
96
Color depth can be 8 or 16. In 8 bits you can access to color component
97
using (uchar*), in 16 bits using (ushort*).
99
- Size size of image in number of pixels ('width' and 'height').
100
- The max average of RGB components from decoded picture.
101
- 'false' is returned if decoding failed, else 'true'.
103
bool decodeHalfRAWImage(const QString& filePath, RawDecodingSettings rawDecodingSettings,
104
QByteArray &imageData, int &width, int &height, int &rgbmax);
106
/** Extract a full size of RAW data from 'filePath' picture file using
107
'rawDecodingSettings' settings. This is a cancelable method witch require
108
a class instance to run because RAW pictures decoding can take a while.
112
- A byte array container ('imageData') with picture data. Pixels order is RGB.
113
Color depth can be 8 or 16. In 8 bits you can access to color component
114
using (uchar*), in 16 bits using (ushort*).
116
- Size size of image in number of pixels ('width' and 'height').
117
- The max average of RGB components from decoded picture.
118
- 'false' is returned if decoding failed, else 'true'.
120
bool decodeRAWImage(const QString& filePath, RawDecodingSettings rawDecodingSettings,
121
QByteArray &imageData, int &width, int &height, int &rgbmax);
123
/** To cancel 'decodeHalfRAWImage' and 'decodeRAWImage' methods running
124
in a separate thread.
130
/** Used internally to cancel RAW decoding operation. Normally, you don't need to use it
131
directly, excepted if you derivated this class. Usual way is to use cancel() method
135
/** The settings container used to perform RAW pictures decoding. See 'rawdecodingsetting.h'
138
RawDecodingSettings m_rawDecodingSettings;
142
/** Re-implement this method to control the cancelisation of loop witch wait data
143
from RAW decoding process with your propers envirronement.
144
By default, this method check if m_cancel is true.
146
NOTE: RAW decoding is divided to 3 stages :
148
1-demosaising from dcraw. no progress feedback is available. We using a pseudo
149
progress value. You can control this stage using checkToCancelWaitingData() and
150
setWaitingDataProgress() methods.
152
2-decoding data reception from dcraw. You can control this stage using
153
checkToCancelRecievingData() and setRecievingDataProgress() methods.
155
3-storage decoded data in your application using the QByteArray container.
157
virtual bool checkToCancelWaitingData();
159
/** Re-implement this method to control the cancelisation of the loop which receives data
160
from RAW decoding process with your proper environment.
161
By default, this method check if m_cancel is true.
163
virtual bool checkToCancelRecievingData();
165
/** Re-implement this method to control the pseudo progress value during RAW decoding (when dcraw run with an
166
internal loop without feedback) with your proper environment. By default, this method do nothing.
167
Progress value average for this stage is 0%-n%, with 'n' == 40% max (see setWaitingDataProgress() method).
169
virtual void setWaitingDataProgress(double value);
171
/** Re-implement this method to control the progress value during RAW decoding (when dcraw return data)
172
with your proper environment. By default, this method do nothing.
173
Progress value average for this stage is n%-70%, with 'n' == 40% max (see setWaitingDataProgress() method).
175
virtual void setRecievingDataProgress(double value);
179
bool loadFromDcraw(const QString& filePath, QByteArray &imageData,
180
int &width, int &height, int &rgbmax);
183
virtual void customEvent(QCustomEvent *);
187
void slotProcessExited(KProcess *);
188
void slotReceivedStdout(KProcess *, char *, int);
189
void slotReceivedStderr(KProcess *, char *, int);
190
void slotContinueQuery();
197
} // namespace KDcrawIface
199
#endif /* KDCRAW_H */