1 | /* |
2 | SPDX-FileCopyrightText: 2020 Kai Uwe Broulik <kde@broulik.de> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #ifndef KIMG_ANI_P_H |
8 | #define KIMG_ANI_P_H |
9 | |
10 | #include <QImageIOPlugin> |
11 | #include <QSize> |
12 | |
13 | class ANIHandler : public QImageIOHandler |
14 | { |
15 | public: |
16 | ANIHandler(); |
17 | |
18 | bool canRead() const override; |
19 | bool read(QImage *image) override; |
20 | |
21 | int currentImageNumber() const override; |
22 | int imageCount() const override; |
23 | bool jumpToImage(int imageNumber) override; |
24 | bool jumpToNextImage() override; |
25 | |
26 | int loopCount() const override; |
27 | int nextImageDelay() const override; |
28 | |
29 | bool supportsOption(ImageOption option) const override; |
30 | QVariant option(ImageOption option) const override; |
31 | |
32 | static bool canRead(QIODevice *device); |
33 | |
34 | private: |
35 | bool ensureScanned() const; |
36 | |
37 | bool m_scanned = false; |
38 | |
39 | int m_currentImageNumber = 0; |
40 | |
41 | int m_frameCount = 0; // "physical" frames |
42 | int m_imageCount = 0; // logical images |
43 | // Stores a custom sequence of images |
44 | QList<int> m_imageSequence; |
45 | // and the corresponding offsets where they are |
46 | // since we can't read the image data sequentally in this case then |
47 | QList<qint64> m_frameOffsets; |
48 | qint64 m_firstFrameOffset = 0; |
49 | |
50 | int m_displayRate = 0; |
51 | QList<int> m_displayRates; |
52 | |
53 | QString m_name; |
54 | QString m_artist; |
55 | QSize m_size; |
56 | }; |
57 | |
58 | class ANIPlugin : public QImageIOPlugin |
59 | { |
60 | Q_OBJECT |
61 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "ani.json" ) |
62 | |
63 | public: |
64 | Capabilities capabilities(QIODevice *device, const QByteArray &format) const override; |
65 | QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const override; |
66 | }; |
67 | |
68 | #endif // KIMG_ANI_P_H |
69 | |