File indexing completed on 2024-04-28 15:25:38
0001 /* 0002 SPDX-FileCopyrightText: 2020 Kai Uwe Broulik <kde@broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KIMG_ANI_P_H 0008 #define KIMG_ANI_P_H 0009 0010 #include <QImageIOPlugin> 0011 #include <QSize> 0012 0013 class ANIHandler : public QImageIOHandler 0014 { 0015 public: 0016 ANIHandler(); 0017 0018 bool canRead() const override; 0019 bool read(QImage *image) override; 0020 0021 int currentImageNumber() const override; 0022 int imageCount() const override; 0023 bool jumpToImage(int imageNumber) override; 0024 bool jumpToNextImage() override; 0025 0026 int loopCount() const override; 0027 int nextImageDelay() const override; 0028 0029 bool supportsOption(ImageOption option) const override; 0030 QVariant option(ImageOption option) const override; 0031 0032 static bool canRead(QIODevice *device); 0033 0034 private: 0035 bool ensureScanned() const; 0036 0037 bool m_scanned = false; 0038 0039 int m_currentImageNumber = 0; 0040 0041 int m_frameCount = 0; // "physical" frames 0042 int m_imageCount = 0; // logical images 0043 // Stores a custom sequence of images 0044 QVector<int> m_imageSequence; 0045 // and the corresponding offsets where they are 0046 // since we can't read the image data sequentally in this case then 0047 QVector<qint64> m_frameOffsets; 0048 qint64 m_firstFrameOffset = 0; 0049 0050 int m_displayRate = 0; 0051 QVector<int> m_displayRates; 0052 0053 QString m_name; 0054 QString m_artist; 0055 QSize m_size; 0056 }; 0057 0058 class ANIPlugin : public QImageIOPlugin 0059 { 0060 Q_OBJECT 0061 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "ani.json") 0062 0063 public: 0064 Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; 0065 QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; 0066 }; 0067 0068 #endif // KIMG_ANI_P_H