Krita Source Code Documentation
Loading...
Searching...
No Matches
ColorModelCheck.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 COLORMODELCHECK_H
8#define COLORMODELCHECK_H
9
11#include <KoID.h>
12#include <klocalizedstring.h>
13#include <kis_image.h>
14#include <KoColorSpace.h>
16
18{
19public:
20
21 ColorModelCheck(const KoID &colorModelID, const KoID &colorDepthID, const QString &id, Level level, const QString &customWarning = QString())
22 : KisExportCheckBase(id, level, customWarning)
23 , m_colorModelID(colorModelID)
24 , m_colorDepthID(colorDepthID)
25 {
26 Q_ASSERT(!colorModelID.name().isEmpty());
27 Q_ASSERT(!colorDepthID.name().isEmpty());
28
29 if (customWarning.isEmpty()) {
30 m_warning = i18nc("image conversion warning",
31 "The color model <b>%1</b> or channel depth <b>%2</b> cannot be saved to this format. Your image will be converted.",
34 }
35 }
36
37 bool checkNeeded(KisImageSP image) const override
38 {
39 return (image->colorSpace()->colorModelId() == m_colorModelID && image->colorSpace()->colorDepthId() == m_colorDepthID);
40 }
41
42 Level check(KisImageSP /*image*/) const override
43 {
44 return m_level;
45 }
46
49};
50
52{
53public:
54
55 ColorModelCheckFactory(const KoID &colorModelID, const KoID &colorDepthId)
56 : m_colorModelID(colorModelID)
57 , m_colorDepthID(colorDepthId)
58 {
59 }
60
62
63 KisExportCheckBase *create(KisExportCheckBase::Level level, const QString &customWarning) override
64 {
65 return new ColorModelCheck(m_colorModelID, m_colorDepthID, id(), level, customWarning);
66 }
67
68 QString id() const override {
69 return "ColorModelCheck/" + m_colorModelID.id() + "/" + m_colorDepthID.id();
70 }
71
74};
75
76#endif // COLORMODELCHECK_H
~ColorModelCheckFactory() override
ColorModelCheckFactory(const KoID &colorModelID, const KoID &colorDepthId)
KisExportCheckBase * create(KisExportCheckBase::Level level, const QString &customWarning) override
QString id() const override
bool checkNeeded(KisImageSP image) const override
const KoID m_colorModelID
ColorModelCheck(const KoID &colorModelID, const KoID &colorDepthID, const QString &id, Level level, const QString &customWarning=QString())
Level check(KisImageSP) const override
const KoID m_colorDepthID
The KisExportCheckBase class defines the interface of the individual checks of an export filter's cap...
virtual QString id() const
const KoColorSpace * colorSpace() const
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
Definition KoID.h:30
QString name() const
Definition KoID.cpp:68
QString id() const
Definition KoID.cpp:63