Krita Source Code Documentation
Loading...
Searching...
No Matches
CheckImageSize.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 <kis_image_ImageSize_interface.h>
15#include <KoColorSpace.h>
16
18{
19public:
20
21 ImageSizeCheck(int maxWidth, int maxHeight, const QString &id, Level level, const QString &customWarning = QString())
22 : KisExportCheckBase(id, level, customWarning, true)
23 , m_maxW(maxWidth)
24 , m_maxH(maxHeight)
25 {
26 if (customWarning.isEmpty()) {
27 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);
28 }
29 }
30
31 bool checkNeeded(KisImageSP image) const
32 {
33 return image->width() <= m_maxW && image->height() <= m_maxH;
34 }
35
36 Level check(KisImageSP /*image*/) const
37 {
38 return m_level;
39 }
40
41 int m_maxW;
42 int m_maxH;
43};
44
46{
47public:
48
50
52
53 KisExportCheckBase *create(int maxWidth, int maxHeight, KisExportCheckBase::Level level, const QString &customWarning)
54 {
55 return new ImageSizeCheck(maxWidth, maxHeight, id(), level, customWarning);
56 }
57
58 QString id() const {
59 return "ImageSizeCheck";
60 }
61};
62
63
64#endif // CHECKIMAGESIZE_H
KisExportCheckBase * create(int maxWidth, int maxHeight, KisExportCheckBase::Level level, const QString &customWarning)
virtual ~ImageSizeCheckFactory()
bool checkNeeded(KisImageSP image) const
Level check(KisImageSP) const
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...
virtual QString id() const
qint32 width() const
qint32 height() const