~ubuntu-branches/ubuntu/oneiric/libkdcraw/oneiric-proposed

« back to all changes in this revision

Viewing changes to libkdcraw/libkdcraw/kdcraw.h

  • Committer: Bazaar Package Importer
  • Author(s): Philip Muškovac
  • Date: 2011-07-08 09:30:26 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110708093026-deas159t23p3w3gq
Tags: 4:4.6.90+repack1-0ubuntu1
* New upstream release candidate 
* Update for split packaging

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ============================================================
2
 
 *
3
 
 * This file is a part of kipi-plugins project
4
 
 * http://www.kipi-plugins.org
5
 
 *
6
 
 * Date        : 2006-12-09
7
 
 * Description : a tread-safe dcraw program interface
8
 
 *
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>
12
 
 *
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.
17
 
 *
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.
22
 
 *
23
 
 * ============================================================ */
24
 
 
25
 
#ifndef KDCRAW_H
26
 
#define KDCRAW_H
27
 
 
28
 
// Qt Includes.
29
 
 
30
 
#include <qstring.h>
31
 
#include <qobject.h>
32
 
#include <qimage.h>
33
 
 
34
 
// Local includes.
35
 
 
36
 
#include "libkdcraw_export.h"
37
 
#include "rawdecodingsettings.h"
38
 
#include "dcrawinfocontainer.h"
39
 
 
40
 
class QCustomEvent;
41
 
 
42
 
class KProcess;
43
 
 
44
 
namespace KDcrawIface
45
 
{
46
 
 
47
 
class KDcrawPriv;
48
 
 
49
 
class LIBKDCRAW_EXPORT KDcraw : public QObject
50
 
{
51
 
    Q_OBJECT
52
 
 
53
 
public:
54
 
 
55
 
    /** Standard constructor. */
56
 
    KDcraw();
57
 
 
58
 
    /** Standard destructor. */
59
 
    virtual ~KDcraw();
60
 
 
61
 
public:
62
 
 
63
 
    /** Return a string version of libkdcraw release */
64
 
    static QString version();
65
 
 
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(). 
68
 
    */
69
 
    static bool loadDcrawPreview(QImage& image, const QString& path);
70
 
 
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.
73
 
    */
74
 
    static bool loadEmbeddedPreview(QImage& image, const QString& path);
75
 
 
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.
78
 
    */
79
 
    static bool loadHalfPreview(QImage& image, const QString& path);
80
 
 
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.
84
 
    */ 
85
 
    static bool rawFileIdentify(DcrawInfoContainer& identify, const QString& path);
86
 
 
87
 
public: 
88
 
 
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.
92
 
 
93
 
        This method return:
94
 
 
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*).
98
 
 
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'.  
102
 
    */
103
 
    bool decodeHalfRAWImage(const QString& filePath, RawDecodingSettings rawDecodingSettings, 
104
 
                            QByteArray &imageData, int &width, int &height, int &rgbmax);
105
 
 
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.
109
 
 
110
 
        This method return:
111
 
 
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*).
115
 
 
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'.  
119
 
    */
120
 
    bool decodeRAWImage(const QString& filePath, RawDecodingSettings rawDecodingSettings, 
121
 
                        QByteArray &imageData, int &width, int &height, int &rgbmax);
122
 
 
123
 
    /** To cancel 'decodeHalfRAWImage' and 'decodeRAWImage' methods running 
124
 
        in a separate thread.
125
 
    */
126
 
    void cancel();
127
 
 
128
 
protected:
129
 
 
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 
132
 
    */
133
 
    bool                m_cancel;
134
 
 
135
 
    /** The settings container used to perform RAW pictures decoding. See 'rawdecodingsetting.h' 
136
 
        for details.
137
 
    */
138
 
    RawDecodingSettings m_rawDecodingSettings;
139
 
 
140
 
protected:
141
 
 
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.
145
 
 
146
 
        NOTE: RAW decoding is divided to 3 stages : 
147
 
 
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.
151
 
 
152
 
              2-decoding data reception from dcraw. You can control this stage using 
153
 
                checkToCancelRecievingData() and setRecievingDataProgress() methods. 
154
 
 
155
 
              3-storage decoded data in your application using the QByteArray container.
156
 
    */
157
 
    virtual bool checkToCancelWaitingData();
158
 
 
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.
162
 
    */
163
 
    virtual bool checkToCancelRecievingData();
164
 
 
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).
168
 
    */
169
 
    virtual void setWaitingDataProgress(double value);
170
 
 
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).
174
 
    */
175
 
    virtual void setRecievingDataProgress(double value);
176
 
 
177
 
private:
178
 
 
179
 
    bool loadFromDcraw(const QString& filePath, QByteArray &imageData, 
180
 
                       int &width, int &height, int &rgbmax);
181
 
    void startProcess();
182
 
 
183
 
    virtual void customEvent(QCustomEvent *);
184
 
 
185
 
private slots:
186
 
 
187
 
    void slotProcessExited(KProcess *);
188
 
    void slotReceivedStdout(KProcess *, char *, int);
189
 
    void slotReceivedStderr(KProcess *, char *, int);
190
 
    void slotContinueQuery();
191
 
 
192
 
private:
193
 
 
194
 
    KDcrawPriv *d;
195
 
};
196
 
 
197
 
}  // namespace KDcrawIface
198
 
 
199
 
#endif /* KDCRAW_H */