digiKam
dngwriter_p.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2008-09-25
7  * Description : a tool to convert RAW file to DNG
8  *
9  * Copyright (C) 2008-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * ============================================================ */
22 
23 #ifndef DIGIKAM_DNG_WRITER_PRIVATE_H
24 #define DIGIKAM_DNG_WRITER_PRIVATE_H
25 
26 #include "dngwriter.h"
27 
28 // Qt includes
29 
30 #include <QImage>
31 #include <QString>
32 #include <QByteArray>
33 #include <QFile>
34 #include <QFileInfo>
35 #include <QIODevice>
36 #include <QTemporaryFile>
37 #include <QDateTime>
38 #include <QPointer>
39 #include <QScopedPointer>
40 
41 // Local includes
42 
43 #include "drawdecoder.h"
44 
45 // DNG SDK includes
46 
47 #include "dng_camera_profile.h"
48 #include "dng_color_space.h"
49 #include "dng_exceptions.h"
50 #include "dng_file_stream.h"
51 #include "dng_globals.h"
52 #include "dng_host.h"
53 #include "dng_ifd.h"
54 #include "dng_image_writer.h"
55 #include "dng_info.h"
56 #include "dng_linearization_info.h"
57 #include "dng_memory_stream.h"
58 #include "dng_mosaic_info.h"
59 #include "dng_negative.h"
60 #include "dng_preview.h"
61 #include "dng_read_image.h"
62 #include "dng_render.h"
63 #include "dng_simple_image.h"
64 #include "dng_tag_codes.h"
65 #include "dng_tag_types.h"
66 #include "dng_tag_values.h"
67 #include "dng_xmp.h"
68 #include "dng_xmp_sdk.h"
69 
70 // XMP SDK includes
71 
72 #include "XMP_Version.h"
73 
74 // Local includes
75 
76 #include "digikam_debug.h"
77 #include "digikam_version.h"
78 #include "dfileoperations.h"
79 #include "dmetadata.h"
80 #include "exiftoolparser.h"
81 #include "exiftoolprocess.h"
82 
83 #define CHUNK 65536
84 
85 namespace Digikam
86 {
87 
88 class DNGWriterHost;
89 
90 class Q_DECL_HIDDEN DNGWriter::Private
91 {
92 
93 public:
94 
96  {
97  Unknown = 1,
102  FourColor
103  };
104 
105 public:
106 
107  explicit Private(DNGWriter* const dd);
108  ~Private();
109 
110 public:
111 
112  void reset();
113  void cleanup();
114  dng_date_time dngDateTime(const QDateTime& qDT) const;
115 
116  bool fujiRotate(QByteArray& rawData, DRawInfo& identify) const;
117 
118  QString dngErrorCodeToString(int errorCode) const;
119 
120  QString dngBayerPatternToString(int pattern) const;
121 
125  int debugExtractedRAWData(const QByteArray& rawData);
126 
127 public:
128 
129  // DNG processing stages.
130 
131  int importRaw(DRawInfo* const identify,
132  DRawInfo* const identifyMake);
133 
134  int identMosaic(DRawInfo* const identify,
135  DRawInfo* const identifyMake);
136 
137  int createNegative(AutoPtr<dng_negative>& negative,
138  DRawInfo* const identify);
139 
140  int storeExif(DNGWriterHost& host,
141  AutoPtr<dng_negative>& negative,
142  DRawInfo* const identify,
143  DRawInfo* const identifyMake,
144  DMetadata* const meta);
145 
146  int storeMakernote(DNGWriterHost& host,
147  AutoPtr<dng_negative>& negative,
148  DRawInfo* const identify,
149  DRawInfo* const identifyMake,
150  DMetadata* const meta);
151 
152  int storeXmp(DNGWriterHost& host,
153  AutoPtr<dng_negative>& negative,
154  DRawInfo* const identify,
155  DRawInfo* const identifyMake,
156  DMetadata* const meta);
157 
158  int backupRaw(DNGWriterHost& host,
159  AutoPtr<dng_negative>& negative);
160 
161  int exportTarget(DNGWriterHost& host,
162  AutoPtr<dng_negative>& negative,
163  AutoPtr<dng_image>& image);
164 
165  int exifToolPostProcess();
166 
167 private:
168 
169  void backportNikonMakerNote(DMetadata* const meta);
170  void backportCanonMakerNote(DMetadata* const meta);
171  void backportPentaxMakerNote(DMetadata* const meta);
172  void backportOlympusMakerNote(DMetadata* const meta);
173  void backportPanasonicMakerNote(DMetadata* const meta);
174  void backportSonyMakerNote(DMetadata* const meta);
175  void storeLensInformation();
176  void backupMakernote(DNGWriterHost& host,
177  AutoPtr<dng_negative>& negative,
178  DRawInfo* const identify,
179  DRawInfo* const identifyMake,
180  DMetadata* const meta);
181 
182 public:
183 
186  uint32 filter;
187 
188  bool metaLoaded;
189  bool cancel;
193 
199  int width;
200  int height;
201 
202  QString inputFile;
203  QString outputFile;
204  QString dngFilePath;
205  QByteArray rawData;
206 
207  QFileInfo inputInfo;
208  QFileInfo outputInfo;
209  QDateTime fileDate;
210 
211  dng_date_time_info orgDateTimeInfo;
212  dng_rect activeArea;
213  dng_exif* exif;
214 };
215 
216 } // namespace Digikam
217 
218 #endif // DIGIKAM_DNG_WRITER_PRIVATE_H
Definition: dmetadata.h:55
Definition: dngwriterhost.h:35
Definition: dngwriter_p.h:91
QString inputFile
Definition: dngwriter_p.h:202
QByteArray rawData
Definition: dngwriter_p.h:205
bool cancel
Definition: dngwriter_p.h:189
int outputWidth
Definition: dngwriter_p.h:198
QFileInfo inputInfo
Definition: dngwriter_p.h:207
bool metaLoaded
Set to true if metadata are properly loaded at Exif stage.
Definition: dngwriter_p.h:188
int height
Definition: dngwriter_p.h:200
DNGBayerPattern
Definition: dngwriter_p.h:96
@ LinearRaw
Definition: dngwriter_p.h:98
@ Fuji
Definition: dngwriter_p.h:100
@ Standard
Definition: dngwriter_p.h:99
@ Fuji6x6
Definition: dngwriter_p.h:101
QString dngFilePath
Definition: dngwriter_p.h:204
int outputHeight
Definition: dngwriter_p.h:197
QFileInfo outputInfo
Definition: dngwriter_p.h:208
bool jpegLossLessCompression
Definition: dngwriter_p.h:190
uint32 filter
Definition: dngwriter_p.h:186
int previewMode
Definition: dngwriter_p.h:194
dng_rect activeArea
Definition: dngwriter_p.h:212
int width
Definition: dngwriter_p.h:199
DNGBayerPattern bayerPattern
Definition: dngwriter_p.h:185
dng_date_time_info orgDateTimeInfo
Definition: dngwriter_p.h:211
bool updateFileDate
Definition: dngwriter_p.h:191
QString outputFile
Definition: dngwriter_p.h:203
int activeHeight
Definition: dngwriter_p.h:196
dng_exif * exif
Instance to Exif DNG SDK container.
Definition: dngwriter_p.h:213
DNGWriter * parent
Parent class instance.
Definition: dngwriter_p.h:184
bool backupOriginalRawFile
Definition: dngwriter_p.h:192
QDateTime fileDate
Definition: dngwriter_p.h:209
int activeWidth
Definition: dngwriter_p.h:195
Definition: dngwriter.h:40
Definition: drawinfo.h:47
Definition: datefolderview.cpp:43