File indexing completed on 2025-01-05 03:56:02
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2008-09-25 0007 * Description : a tool to convert RAW file to DNG 0008 * 0009 * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #ifndef DIGIKAM_DNG_WRITER_PRIVATE_H 0016 #define DIGIKAM_DNG_WRITER_PRIVATE_H 0017 0018 #include "dngwriter.h" 0019 0020 // Qt includes 0021 0022 #include <QImage> 0023 #include <QString> 0024 #include <QByteArray> 0025 #include <QFile> 0026 #include <QFileInfo> 0027 #include <QIODevice> 0028 #include <QTemporaryFile> 0029 #include <QDateTime> 0030 #include <QPointer> 0031 #include <QScopedPointer> 0032 0033 // Local includes 0034 0035 #include "drawdecoder.h" 0036 0037 // DNG SDK includes 0038 0039 #include "dng_camera_profile.h" 0040 #include "dng_color_space.h" 0041 #include "dng_exceptions.h" 0042 #include "dng_file_stream.h" 0043 #include "dng_globals.h" 0044 #include "dng_host.h" 0045 #include "dng_ifd.h" 0046 #include "dng_image_writer.h" 0047 #include "dng_info.h" 0048 #include "dng_linearization_info.h" 0049 #include "dng_memory_stream.h" 0050 #include "dng_mosaic_info.h" 0051 #include "dng_negative.h" 0052 #include "dng_preview.h" 0053 #include "dng_read_image.h" 0054 #include "dng_render.h" 0055 #include "dng_simple_image.h" 0056 #include "dng_tag_codes.h" 0057 #include "dng_tag_types.h" 0058 #include "dng_tag_values.h" 0059 #include "dng_xmp.h" 0060 #include "dng_xmp_sdk.h" 0061 0062 // XMP SDK includes 0063 0064 #include "XMP_Version.h" 0065 0066 // Local includes 0067 0068 #include "digikam_debug.h" 0069 #include "digikam_version.h" 0070 #include "dfileoperations.h" 0071 #include "dmetadata.h" 0072 #include "exiftoolparser.h" 0073 #include "exiftoolprocess.h" 0074 0075 #define CHUNK 65536 0076 0077 namespace Digikam 0078 { 0079 0080 class DNGWriterHost; 0081 0082 class Q_DECL_HIDDEN DNGWriter::Private 0083 { 0084 0085 public: 0086 0087 enum DNGBayerPattern 0088 { 0089 Unknown = 1, 0090 LinearRaw, 0091 Standard, 0092 Fuji, 0093 Fuji6x6, 0094 FourColor 0095 }; 0096 0097 public: 0098 0099 explicit Private(DNGWriter* const dd); 0100 ~Private(); 0101 0102 public: 0103 0104 void reset(); 0105 void cleanup(); 0106 dng_date_time dngDateTime(const QDateTime& qDT) const; 0107 0108 bool fujiRotate(QByteArray& rawData, DRawInfo& identify) const; 0109 0110 QString dngErrorCodeToString(int errorCode) const; 0111 0112 QString dngBayerPatternToString(int pattern) const; 0113 0114 /** 0115 * Code to hack RAW data extraction. 0116 */ 0117 int debugExtractedRAWData(const QByteArray& rawData); 0118 0119 public: 0120 0121 // DNG processing stages. 0122 0123 int importRaw(DRawInfo* const identify, 0124 DRawInfo* const identifyMake); 0125 0126 int identMosaic(DRawInfo* const identify, 0127 DRawInfo* const identifyMake); 0128 0129 int createNegative(AutoPtr<dng_negative>& negative, 0130 DRawInfo* const identify); 0131 0132 int storeExif(DNGWriterHost& host, 0133 AutoPtr<dng_negative>& negative, 0134 DRawInfo* const identify, 0135 DRawInfo* const identifyMake, 0136 DMetadata* const meta); 0137 0138 int storeMakernote(DNGWriterHost& host, 0139 AutoPtr<dng_negative>& negative, 0140 DRawInfo* const identify, 0141 DRawInfo* const identifyMake, 0142 DMetadata* const meta); 0143 0144 int storeXmp(DNGWriterHost& host, 0145 AutoPtr<dng_negative>& negative, 0146 DRawInfo* const identify, 0147 DRawInfo* const identifyMake, 0148 DMetadata* const meta); 0149 0150 int backupRaw(DNGWriterHost& host, 0151 AutoPtr<dng_negative>& negative); 0152 0153 int exportTarget(DNGWriterHost& host, 0154 AutoPtr<dng_negative>& negative, 0155 AutoPtr<dng_image>& image); 0156 0157 int exifToolPostProcess(); 0158 0159 private: 0160 0161 void backportNikonMakerNote(DMetadata* const meta); 0162 void backportCanonMakerNote(DMetadata* const meta); 0163 void backportPentaxMakerNote(DMetadata* const meta); 0164 void backportOlympusMakerNote(DMetadata* const meta); 0165 void backportPanasonicMakerNote(DMetadata* const meta); 0166 void backportSonyMakerNote(DMetadata* const meta); 0167 void storeLensInformation(); 0168 void backupMakernote(DNGWriterHost& host, 0169 AutoPtr<dng_negative>& negative, 0170 DRawInfo* const identify, 0171 DRawInfo* const identifyMake, 0172 DMetadata* const meta); 0173 0174 public: 0175 0176 DNGWriter* parent; ///< Parent class instance. 0177 DNGBayerPattern bayerPattern; 0178 uint32 filter; 0179 0180 bool metaLoaded; ///< Set to true if metadata are properly loaded at Exif stage. 0181 bool cancel; 0182 bool jpegLossLessCompression; 0183 bool updateFileDate; 0184 bool backupOriginalRawFile; 0185 0186 int previewMode; 0187 int activeWidth; 0188 int activeHeight; 0189 int outputHeight; 0190 int outputWidth; 0191 int width; 0192 int height; 0193 0194 QString inputFile; 0195 QString outputFile; 0196 QString dngFilePath; 0197 QByteArray rawData; 0198 0199 QFileInfo inputInfo; 0200 QFileInfo outputInfo; 0201 QDateTime fileDate; 0202 0203 dng_date_time_info orgDateTimeInfo; 0204 dng_rect activeArea; 0205 dng_exif* exif; ///< Instance to Exif DNG SDK container. 0206 }; 0207 0208 } // namespace Digikam 0209 0210 #endif // DIGIKAM_DNG_WRITER_PRIVATE_H