Krita Source Code Documentation
Loading...
Searching...
No Matches
ImageSizeCheck.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef CHECKIMAGESIZE_H
8#define CHECKIMAGESIZE_H
9
11#include <KoID.h>
12#include <klocalizedstring.h>
13#include <kis_image.h>
14#include "kritaimpex_export.h"
15
16class KRITAIMPEX_EXPORT ImageSizeCheck : public KisExportCheckBase
17{
18public:
19
20 ImageSizeCheck(int maxWidth, int maxHeight, const QString &id, Level level, const QString &customWarning = QString())
21 : KisExportCheckBase(id, level, customWarning, true)
22 , m_maxW(maxWidth)
23 , m_maxH(maxHeight)
24 {
25 if (customWarning.isEmpty()) {
26 m_warning = i18nc("image conversion warning", "This image is larger than <b>%1 x %2</b>. Images this size cannot be saved to this format.", m_maxW, m_maxH);
27 }
28 }
29
30 bool checkNeeded(KisImageSP image) const override
31 {
32 return image->width() >= m_maxW && image->height() >= m_maxH;
33 }
34
35 Level check(KisImageSP /*image*/) const override
36 {
37 return m_level;
38 }
39
40 int m_maxW;
41 int m_maxH;
42};
43
44class KRITAIMPEX_EXPORT ImageSizeCheckFactory : public KisExportCheckFactory
45{
46public:
47
49
51
52 KisExportCheckBase *create( KisExportCheckBase::Level level, const QString &customWarning = QString()) override
53 {
54 return new ImageSizeCheck(100000000, 100000000, id(), level, customWarning);
55 }
56
57 KisExportCheckBase *create(int maxWidth, int maxHeight, KisExportCheckBase::Level level, const QString &customWarning = QString())
58 {
59 return new ImageSizeCheck(maxWidth, maxHeight, id(), level, customWarning);
60 }
61
62 QString id() const override {
63 return "ImageSizeCheck";
64 }
65};
66
67
68#endif // CHECKIMAGESIZE_H
KisExportCheckBase * create(KisExportCheckBase::Level level, const QString &customWarning=QString()) override
KisExportCheckBase * create(int maxWidth, int maxHeight, KisExportCheckBase::Level level, const QString &customWarning=QString())
QString id() const override
~ImageSizeCheckFactory() override
bool checkNeeded(KisImageSP image) const override
Level check(KisImageSP) const override
ImageSizeCheck(int maxWidth, int maxHeight, 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...
qint32 width() const
qint32 height() const