File indexing completed on 2024-04-28 03:54:45
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 * When the quality value is negative (but not -1), we assume we want to work with flags according to the following scheme: 0044 * 3 2 1 0 0045 * 1 0 9 8 7 6 5 4 3 2 1 0 9 87 6 5 4 3 2 1098 7654 3210 0046 * 1 _ _ _ _ _ _ _ _ _ _ S F NN E H B A W CCCC IIII ____ 0047 * 0048 * Where: 0049 * _: reserved (should be zero) 0050 * I: interpolation quality (0 - linear, 1 - VNG, 2 - PPG, 3 - AHD, 4 - DCB, 11 - DHT, 12 - AAHD) 0051 * C: output colorspace (0 - raw, 1 - sRGB, 2 - Adobe, 3 - Wide, 4 - ProPhoto, 5 - XYZ, 6 - ACES, 7 - DCI-P3, 8 - Rec2020) 0052 * W: use camera white balace (0 - off, 1 - on) 0053 * A: use auto white balance (0 - off, 1 - on) 0054 * B: output bit per sample (0 - 8-bits, 1 - 16-bits) 0055 * H: half size image (0 - off, 1 - on) 0056 * E: DCB color enhance (0 - off, 1 - on) 0057 * N: FBDD noise reduction (0 - off, 1 - light, 2 - full) 0058 * F: Interpolate RGGB as four colors (0 - off, 1 - on) 0059 * S: Don't stretch or rotate raw pixels (0 - rotate and stretch, 1 - don't rotate and stretch) 0060 * @note It is safe to set both W and A: W is used if camera white balance is found, otherwise A is used. 0061 * 0062 * When quality is a positive value, a value between 0 and 100 is expected. The values are interpreted as follows: 0063 * - 00-09: I = 0, C = 1, B = 0, W = 1, A = 1, H = 1 (Linear, sRGB, 8-bits, Camera White, Auto White, Half-size) 0064 * - 10-19: I = 0, C = 1, B = 0, W = 1, A = 1, H = 0 (Linear, sRGB, 8-bits, Camera White, Auto White) 0065 * - 20-29: I = 3, C = 1, B = 0, W = 1, A = 1, H = 0 (AHD, sRGB, 8-bits, Camera White, Auto White) 0066 * - 30-39: I = 3, C = 1, B = 1, W = 1, A = 1, H = 0 (AHD, sRGB, 16-bits, Camera White, Auto White) [Default] 0067 * - 40-49: I = 3, C = 2, B = 1, W = 1, A = 1, H = 0 (AHD, Adobe, 16-bits, Camera White, Auto White) 0068 * - 50-59: I = 3, C = 4, B = 1, W = 1, A = 1, H = 0 (AHD, ProPhoto, 16-bits, Camera White, Auto White) 0069 * - 60-69: I = 11, C = 1, B = 0, W = 1, A = 1, H = 0 (DHT, sRGB, 8-bits, Camera White, Auto White) 0070 * - 70-79: I = 11, C = 1, B = 1, W = 1, A = 1, H = 0 (DHT, sRGB, 16-bits, Camera White, Auto White) 0071 * - 80-89: I = 11, C = 2, B = 1, W = 1, A = 1, H = 0 (DHT, Adobe, 16-bits, Camera White, Auto White) 0072 * - >= 90: I = 11, C = 4, B = 1, W = 1, A = 1, H = 0 (DHT, ProPhoto, 16-bits, Camera White, Auto White) 0073 * 0074 * When the quality is -1, default quality is used. 0075 */ 0076 qint32 m_quality; 0077 0078 /*! 0079 * \brief m_startPos 0080 * The initial device position to allow multi image load (cache value). 0081 */ 0082 qint64 m_startPos; 0083 }; 0084 0085 class RAWPlugin : public QImageIOPlugin 0086 { 0087 Q_OBJECT 0088 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "raw.json") 0089 0090 public: 0091 Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; 0092 QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; 0093 }; 0094 0095 #endif // KIMG_RAW_P_H