QGIS API Documentation 3.99.0-Master (752b475928d)
Loading...
Searching...
No Matches
qgscoloreffect.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscoloreffect.h
3 ----------------
4 begin : March 2015
5 copyright : (C) 2015 Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSCOLOREFFECT_H
18#define QGSCOLOREFFECT_H
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgsimageoperation.h"
23#include "qgspainteffect.h"
24
25#include <QPainter>
26
34
36{
37
38 public:
39
45 static QgsPaintEffect *create( const QVariantMap &map ) SIP_FACTORY;
46
48
49 Qgis::PaintEffectFlags flags() const override;
50 QString type() const override { return QStringLiteral( "color" ); }
51 QVariantMap properties() const override;
52
54 void readProperties( const QVariantMap &props ) override;
55 QgsColorEffect *clone() const override SIP_FACTORY;
56
64 void setBrightness( int brightness );
65
73 int brightness() const { return mBrightness; }
74
82 void setContrast( int contrast );
83
91 int contrast() const { return mContrast; }
92
100 void setSaturation( double saturation ) { mSaturation = saturation; }
101
109 double saturation() const { return mSaturation; }
110
117
123 QgsImageOperation::GrayscaleMode grayscaleMode() const { return mGrayscaleMode; }
124
132 void setColorizeOn( bool colorizeOn ) { mColorizeOn = colorizeOn; }
133
141 bool colorizeOn() const { return mColorizeOn; }
142
151 void setColorizeColor( const QColor &colorizeColor );
152
161 QColor colorizeColor() const { return mColorizeColor; }
162
171 void setColorizeStrength( int colorizeStrength ) { mColorizeStrength = colorizeStrength; }
172
181 int colorizeStrength() const { return mColorizeStrength; }
182
189 void setOpacity( const double opacity ) { mOpacity = opacity; }
190
197 double opacity() const { return mOpacity; }
198
205 void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
206
213 QPainter::CompositionMode blendMode() const { return mBlendMode; }
214
215 protected:
216
217 void draw( QgsRenderContext &context ) override;
218
219 private:
220
221 double mOpacity = 1.0;
222 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
223 int mBrightness = 0;
224 int mContrast = 0;
225 double mSaturation = 1.0;
227 bool mColorizeOn = false;
228 QColor mColorizeColor;
229 int mColorizeStrength = 100;
230};
231
232#endif // QGSBLUREFFECT_H
233
QFlags< PaintEffectFlag > PaintEffectFlags
Flags which control how paint effects behave.
Definition qgis.h:2815
A paint effect which alters the colors (e.g., brightness, contrast) in a source picture.
bool colorizeOn() const
Returns whether the effect will colorize a picture.
QgsImageOperation::GrayscaleMode grayscaleMode() const
Returns whether the effect will convert a picture to grayscale.
double opacity() const
Returns the opacity for the effect.
void setOpacity(const double opacity)
Sets the opacity for the effect.
QString type() const override
Returns the effect type.
void setSaturation(double saturation)
Sets the saturation modification for the effect.
void setColorizeStrength(int colorizeStrength)
Sets the strength for colorizing a picture.
int colorizeStrength() const
Returns the strength used for colorizing a picture.
void setColorizeOn(bool colorizeOn)
Sets whether the effect should colorize a picture.
static QgsPaintEffect * create(const QVariantMap &map)
Creates a new QgsColorEffect effect from a properties string map.
int contrast() const
Returns the contrast modification for the effect.
int brightness() const
Returns the brightness modification for the effect.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
double saturation() const
Returns the saturation modification for the effect.
QColor colorizeColor() const
Returns the color used for colorizing a picture.
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.
void setGrayscaleMode(QgsImageOperation::GrayscaleMode grayscaleMode)
Sets whether the effect should convert a picture to grayscale.
GrayscaleMode
Modes for converting a QImage to grayscale.
QgsPaintEffect()=default
virtual void readProperties(const QVariantMap &props)=0
Reads a string map of an effect's properties and restores the effect to the state described by the pr...
virtual Qgis::PaintEffectFlags flags() const
Returns flags which specify how the paint effect behaves.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
virtual QVariantMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect's result on to the specified render context.
Contains information about the context of a rendering operation.
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_NODEFAULTCTORS
Definition qgis_sip.h:109