File indexing completed on 2024-04-28 15:25:44
0001 /* 0002 This file is part of the KDE project 0003 0004 SPDX-FileCopyrightText: 2022 Mirco Miranda <mircomir@outlook.com> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KIMG_RAW_P_H 0010 #define KIMG_RAW_P_H 0011 0012 #include <QImageIOPlugin> 0013 0014 class RAWHandler : public QImageIOHandler 0015 { 0016 public: 0017 RAWHandler(); 0018 0019 bool canRead() const override; 0020 bool read(QImage *image) override; 0021 0022 void setOption(ImageOption option, const QVariant &value) override; 0023 bool supportsOption(QImageIOHandler::ImageOption option) const override; 0024 QVariant option(QImageIOHandler::ImageOption option) const override; 0025 0026 bool jumpToNextImage() override; 0027 bool jumpToImage(int imageNumber) override; 0028 int imageCount() const override; 0029 int currentImageNumber() const override; 0030 0031 static bool canRead(QIODevice *device); 0032 0033 private: 0034 qint32 m_imageNumber; 0035 0036 mutable qint32 m_imageCount; 0037 0038 /** 0039 * @brief m_quality 0040 * Change the quality of the conversion. If -1, default quality is used. 0041 * @note Verify that the quality change support has been compiled with supportsOption() 0042 * 0043 * 3 2 1 0 0044 * 1 0 9 8 7 6 5 4 3 2 1 0 9 87 6 5 4 3 2 1098 7654 3210 0045 * _ _ _ _ _ _ _ _ _ _ _ S F NN E H B A W CCCC IIII PPPP 0046 * 0047 * Where: 0048 * 0049 * _: reserved 0050 * P: preset values: *** if set, other flags are ignored! *** 0051 * - 0: Use other flags (no preset) 0052 * - 1: I = 0, C = 1, B = 0, W = 1, A = 1, H = 1 (Linear, sRGB, 8-bits, Camera White, Auto White, Half-size) 0053 * - 2: I = 0, C = 1, B = 0, W = 1, A = 1, H = 0 (Linear, sRGB, 8-bits, Camera White, Auto White) 0054 * - 3: I = 3, C = 1, B = 0, W = 1, A = 1, H = 0 (AHD, sRGB, 8-bits, Camera White, Auto White) 0055 * - 4: I = 3, C = 1, B = 1, W = 1, A = 1, H = 0 (AHD, sRGB, 16-bits, Camera White, Auto White) 0056 * - 5: I = 3, C = 2, B = 1, W = 1, A = 1, H = 0 (AHD, Adobe, 16-bits, Camera White, Auto White) 0057 * - 6: I = 3, C = 4, B = 1, W = 1, A = 1, H = 0 (AHD, ProPhoto, 16-bits, Camera White, Auto White) 0058 * - 7: I = 11, C = 1, B = 0, W = 1, A = 1, H = 0 (DHT, sRGB, 8-bits, Camera White, Auto White) 0059 * - 8: I = 11, C = 1, B = 1, W = 1, A = 1, H = 0 (DHT, sRGB, 16-bits, Camera White, Auto White) 0060 * - 9: I = 11, C = 2, B = 1, W = 1, A = 1, H = 0 (DHT, Adobe, 16-bits, Camera White, Auto White) 0061 * - 10: I = 11, C = 4, B = 1, W = 1, A = 1, H = 0 (DHT, ProPhoto, 16-bits, Camera White, Auto White) 0062 * - 11: reserved 0063 * - 12: reserved 0064 * - 13: reserved 0065 * - 14: reserved 0066 * - 15: reserved 0067 * I: interpolation quality (0 - linear, 1 - VNG, 2 - PPG, 3 - AHD, 4 - DCB, 11 - DHT, 12 - AAHD) 0068 * C: output colorspace (0 - raw, 1 - sRGB, 2 - Adobe, 3 - Wide, 4 - ProPhoto, 5 - XYZ, 6 - ACES, 7 - DCI-P3, 8 - Rec2020) 0069 * W: use camera white balace (0 - off, 1 - on) 0070 * A: use auto white balance (0 - off, 1 - on) 0071 * B: output bit per sample (0 - 8-bits, 1 - 16-bits) 0072 * H: half size image (0 - off, 1 - on) 0073 * E: DCB color enhance (0 - off, 1 - on) 0074 * N: FBDD noise reduction (0 - off, 1 - light, 2 - full) 0075 * F: Interpolate RGGB as four colors (0 - off, 1 - on) 0076 * S: Don't stretch or rotate raw pixels (0 - rotate and stretch, 1 - don't rotate and stretch) 0077 * 0078 * @note It is safe to set both W and A: W is used if camera white balance is found, otherwise A is used. 0079 */ 0080 qint32 m_quality; 0081 0082 /*! 0083 * \brief m_startPos 0084 * The initial device position to allow multi image load (cache value). 0085 */ 0086 qint64 m_startPos; 0087 }; 0088 0089 class RAWPlugin : public QImageIOPlugin 0090 { 0091 Q_OBJECT 0092 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "raw.json") 0093 0094 public: 0095 Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; 0096 QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; 0097 }; 0098 0099 #endif // KIMG_RAW_P_H