KIconThemes 5.109.0
|
Applies effects to icons. More...
#include <KIconEffect>
Public Types | |
enum | Effects { NoEffect , ToGray , Colorize , ToGamma , DeSaturate , ToMonochrome , LastEffect } |
This is the enumeration of all possible icon effects. More... | |
Public Member Functions | |
KIconEffect () | |
Create a new KIconEffect. | |
KIconEffect (const KIconEffect &)=delete | |
QImage | apply (const QImage &src, int effect, float value, const QColor &rgb, bool trans) const |
Applies an effect to an image. | |
QImage | apply (const QImage &src, int effect, float value, const QColor &rgb, const QColor &rgb2, bool trans) const |
QImage | apply (const QImage &src, int group, int state) 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. | |
QPixmap | apply (const QPixmap &src, int effect, float value, const QColor &rgb, const QColor &rgb2, bool trans) const |
QPixmap | apply (const QPixmap &src, int group, int state) const |
Applies an effect to a pixmap. | |
QImage | doublePixels (const QImage &src) const |
Returns an image twice as large, consisting of 2x2 pixels. | |
QString | fingerprint (int group, int state) const |
Returns a fingerprint for the effect by encoding the given group and state into a QString. | |
bool | hasEffect (int group, int state) const |
Tests whether an effect has been configured for the given icon group. | |
void | init () |
Rereads configuration. | |
KIconEffect & | operator= (const KIconEffect &)=delete |
Static Public Member Functions | |
static void | colorize (QImage &image, const QColor &col, float value) |
Colorizes an image with a specific color. | |
static void | deSaturate (QImage &image, float value) |
Desaturates an image. | |
static void | overlay (QImage &src, QImage &overlay) |
Overlays an image with an other image. | |
static void | semiTransparent (QImage &image) |
Renders an image semi-transparent. | |
static void | semiTransparent (QPixmap &pixmap) |
Renders a pixmap semi-transparent. | |
static void | toGamma (QImage &image, float value) |
Changes the gamma value of an image. | |
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. | |
Applies effects to icons.
This class applies effects to icons depending on their state and group. For example, it can be used to make all disabled icons in a toolbar gray.
enum KIconEffect::Effects |
This is the enumeration of all possible icon effects.
Note that 'LastEffect' is no valid icon effect but only used internally to check for invalid icon effects.
KIconEffect::KIconEffect | ( | ) |
Create a new KIconEffect.
You will most likely never have to use this to create a new KIconEffect yourself, as you can use the KIconEffect provided by the global KIconLoader (which itself is accessible by KIconLoader::global()) through its iconEffect() function.
QImage KIconEffect::apply | ( | const QImage & | src, |
int | effect, | ||
float | value, | ||
const QColor & | rgb, | ||
bool | trans | ||
) | const |
Applies an effect to an image.
src | The image. |
effect | The effect to apply, one of KIconEffect::Effects. |
value | Strength of the effect. 0 <= value <= 1. |
rgb | Color parameter for effects that need one. |
trans | Add Transparency if trans = true. |
QImage KIconEffect::apply | ( | const QImage & | src, |
int | group, | ||
int | state | ||
) | const |
Applies an effect to an image.
The effect to apply depends on the group
and state
parameters, and is configured by the user.
src | The image. |
group | The group for the icon, see KIconLoader::Group |
state | The icon's state, see KIconLoader::States |
QPixmap KIconEffect::apply | ( | const QPixmap & | src, |
int | effect, | ||
float | value, | ||
const QColor & | rgb, | ||
bool | trans | ||
) | const |
Applies an effect to a pixmap.
src | The pixmap. |
effect | The effect to apply, one of KIconEffect::Effects. |
value | Strength of the effect. 0 <= value <= 1. |
rgb | Color parameter for effects that need one. |
trans | Add Transparency if trans = true. |
QPixmap KIconEffect::apply | ( | const QPixmap & | src, |
int | group, | ||
int | state | ||
) | const |
Applies an effect to a pixmap.
src | The pixmap. |
group | The group for the icon, see KIconLoader::Group |
state | The icon's state, see KIconLoader::States |
|
static |
Colorizes an image with a specific color.
image | The image |
col | The color with which the image is tinted |
value | Strength of the effect. 0 <= value <= 1 |
|
static |
Desaturates an image.
image | The image |
value | Strength of the effect. 0 <= value <= 1 |
QImage KIconEffect::doublePixels | ( | const QImage & | src | ) | const |
Returns an image twice as large, consisting of 2x2 pixels.
src | the image. |
QString KIconEffect::fingerprint | ( | int | group, |
int | state | ||
) | const |
Returns a fingerprint for the effect by encoding the given group
and state
into a QString.
This is useful for caching.
group | the group, see KIconLoader::Group |
state | the state, see KIconLoader::States |
group+state
bool KIconEffect::hasEffect | ( | int | group, |
int | state | ||
) | const |
Tests whether an effect has been configured for the given icon group.
group | the group to check, see KIconLoader::Group |
state | the state to check, see KIconLoader::States |
group
in state
, otherwise false. void KIconEffect::init | ( | ) |
Rereads configuration.
|
static |
Overlays an image with an other image.
src | The image |
overlay | The image to overlay src with |
|
static |
Renders an image semi-transparent.
image | The image |
|
static |
Renders a pixmap semi-transparent.
pixmap | The pixmap |
|
static |
Changes the gamma value of an image.
image | The image |
value | Strength of the effect. 0 <= value <= 1 |
|
static |
Tints an image gray.
image | The image |
value | Strength of the effect. 0 <= value <= 1 |
|
static |
Produces a monochrome icon with a given foreground and background color.
image | The image |
white | The color with which the white parts of image are painted |
black | The color with which the black parts of image are painted |
value | Strength of the effect. 0 <= value <= 1 |