Krita Source Code Documentation
Loading...
Searching...
No Matches
IntegralFrameDuration.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 L. E. Segovia <amy@amyspark.me>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef INTEGRAL_FRAME_DURATION_H
8#define INTEGRAL_FRAME_DURATION_H
9
10#include <cmath>
11
12#include <klocalizedstring.h>
13
14#include <KoID.h>
15#include <kis_image.h>
17
19#include "kritaimpex_export.h"
20
21class KRITAIMPEX_EXPORT IntegralFrameDurationCheck : public KisExportCheckBase
22{
23public:
24 IntegralFrameDurationCheck(const QString &id,
25 Level level,
26 const QString &customWarning = QString())
27 : KisExportCheckBase(id, level, customWarning)
28 {
29 if (customWarning.isEmpty()) {
30 m_warning =
31 i18nc("image conversion warning",
32 "The image is animated with a frame duration in "
33 "<b>fractions of a millisecond</b>. The "
34 "format cannot represent this, and the frame "
35 "duration will be rounded to the nearest millisecond.");
36 }
37 }
38
39 bool checkNeeded(KisImageSP image) const override
40 {
41 if (!image->animationInterface()->hasAnimation()) {
42 return false;
43 }
44
45 const auto frameDuration = 1000.0
46 / static_cast<double>(image->animationInterface()->framerate());
47
48 return std::round(frameDuration) != frameDuration;
49 }
50
51 Level check(KisImageSP /*image*/) const override
52 {
53 return m_level;
54 }
55};
56
57class KRITAIMPEX_EXPORT IntegralFrameDurationCheckFactory
59{
60public:
62
64
67 const QString &customWarning = QString()) override
68 {
69 return new IntegralFrameDurationCheck(id(), level, customWarning);
70 }
71
72 QString id() const override
73 {
74 return "IntegralFrameDurationCheck";
75 }
76};
77
78#endif // INTEGRAL_FRAME_DURATION_H
KisExportCheckBase * create(KisExportCheckBase::Level level, const QString &customWarning=QString()) override
~IntegralFrameDurationCheckFactory() override=default
Level check(KisImageSP) const override
bool checkNeeded(KisImageSP image) const override
IntegralFrameDurationCheck(const QString &id, Level level, const QString &customWarning=QString())
The KisExportCheckBase class defines the interface of the individual checks of an export filter's cap...
KisImageAnimationInterface * animationInterface() const