KIconThemes 5.109.0
kiconeffect.h
1/* vi: ts=8 sts=4 sw=4
2
3 This file is part of the KDE project, module kdecore.
4 SPDX-FileCopyrightText: 2000 Geert Jansen <jansen@kde.org>
5 SPDX-FileCopyrightText: 2007 Daniel M. Duley <daniel.duley@verizon.net>
6
7 with minor additions and based on ideas from
8 SPDX-FileContributor: Torsten Rahn <torsten@kde.org>
9
10 SPDX-License-Identifier: LGPL-2.0-only
11*/
12
13#ifndef KICONEFFECT_H
14#define KICONEFFECT_H
15
16#include <kiconthemes_export.h>
17
18#include <QColor>
19#include <QImage>
20#include <QPixmap>
21
22#include <memory>
23
24class KIconEffectPrivate;
25
39class KICONTHEMES_EXPORT KIconEffect
40{
41public:
51
52 KIconEffect(const KIconEffect &) = delete;
53 KIconEffect &operator=(const KIconEffect &) = delete;
54
67 enum Effects {
68 NoEffect,
69 ToGray,
70 Colorize,
71 ToGamma,
72 DeSaturate,
73 ToMonochrome,
74 LastEffect,
75 };
76
80 void init();
81
91 bool hasEffect(int group, int state) const;
92
101 QString fingerprint(int group, int state) const;
102
111 QImage apply(const QImage &src, int group, int state) const;
112
122 QImage apply(const QImage &src, int effect, float value, const QColor &rgb, bool trans) const;
123 QImage apply(const QImage &src, int effect, float value, const QColor &rgb, const QColor &rgb2, bool trans) const;
124
132 QPixmap apply(const QPixmap &src, int group, int state) const;
133
143 QPixmap apply(const QPixmap &src, int effect, float value, const QColor &rgb, bool trans) const;
144 QPixmap apply(const QPixmap &src, int effect, float value, const QColor &rgb, const QColor &rgb2, bool trans) const;
145
151 QImage doublePixels(const QImage &src) const;
152
159 static void toGray(QImage &image, float value);
160
168 static void colorize(QImage &image, const QColor &col, float value);
169
178 static void toMonochrome(QImage &image, const QColor &black, const QColor &white, float value);
179
186 static void deSaturate(QImage &image, float value);
187
194 static void toGamma(QImage &image, float value);
195
201 static void semiTransparent(QImage &image);
202
208 static void semiTransparent(QPixmap &pixmap);
209
216 static void overlay(QImage &src, QImage &overlay);
217
218private:
219 std::unique_ptr<KIconEffectPrivate> const d;
220};
221
222#endif
Applies effects to icons.
Definition kiconeffect.h:40
QString fingerprint(int group, int state) const
Returns a fingerprint for the effect by encoding the given group and state into a QString.
static void toGray(QImage &image, float value)
Tints an image gray.
static void toMonochrome(QImage &image, const QColor &black, const QColor &white, float value)
Produces a monochrome icon with a given foreground and background color.
static void semiTransparent(QPixmap &pixmap)
Renders a pixmap semi-transparent.
QImage doublePixels(const QImage &src) const
Returns an image twice as large, consisting of 2x2 pixels.
static void toGamma(QImage &image, float value)
Changes the gamma value of an image.
static void semiTransparent(QImage &image)
Renders an image semi-transparent.
static void deSaturate(QImage &image, float value)
Desaturates an image.
Effects
This is the enumeration of all possible icon effects.
Definition kiconeffect.h:67
void init()
Rereads configuration.
QImage apply(const QImage &src, int effect, float value, const QColor &rgb, bool trans) const
Applies an effect to an image.
QPixmap apply(const QPixmap &src, int effect, float value, const QColor &rgb, bool trans) const
Applies an effect to a pixmap.
static void colorize(QImage &image, const QColor &col, float value)
Colorizes an image with a specific color.
QPixmap apply(const QPixmap &src, int group, int state) const
Applies an effect to a pixmap.
KIconEffect()
Create a new KIconEffect.
bool hasEffect(int group, int state) const
Tests whether an effect has been configured for the given icon group.
QImage apply(const QImage &src, int group, int state) const
Applies an effect to an image.
static void overlay(QImage &src, QImage &overlay)
Overlays an image with an other image.