QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "qgspainteffect.h"
21 #include "qgsimageoperation.h"
22 #include "qgis.h"
23 #include <QPainter>
24 
33 class CORE_EXPORT QgsColorEffect : public QgsPaintEffect
34 {
35 
36  public:
37 
42  static QgsPaintEffect* create( const QgsStringMap& );
43 
45  virtual ~QgsColorEffect();
46 
47  virtual QString type() const override { return QString( "color" ); }
48  virtual QgsStringMap properties() const override;
49  virtual void readProperties( const QgsStringMap& props ) override;
50  virtual QgsPaintEffect* clone() const override;
51 
58  void setBrightness( int brightness ) { mBrightness = qBound( -255, brightness, 255 ); }
59 
66  int brightness() const { return mBrightness; }
67 
74  void setContrast( int contrast ) { mContrast = qBound( -100, contrast, 100 ); }
75 
82  int contrast() const { return mContrast; }
83 
90  void setSaturation( double saturation ) { mSaturation = saturation; }
91 
98  double saturation() const { return mSaturation; }
99 
104  void setGrayscaleMode( QgsImageOperation::GrayscaleMode grayscaleMode ) { mGrayscaleMode = grayscaleMode; }
105 
110  QgsImageOperation::GrayscaleMode grayscaleMode() const { return mGrayscaleMode; }
111 
118  void setColorizeOn( bool colorizeOn ) { mColorizeOn = colorizeOn; }
119 
126  bool colorizeOn() const { return mColorizeOn; }
127 
135  void setColorizeColor( const QColor& colorizeColor );
136 
144  QColor colorizeColor() const { return mColorizeColor; }
145 
153  void setColorizeStrength( int colorizeStrength ) { mColorizeStrength = colorizeStrength; }
154 
162  int colorizeStrength() const { return mColorizeStrength; }
163 
169  void setTransparency( const double transparency ) { mTransparency = transparency; }
170 
176  double transparency() const { return mTransparency; }
177 
183  void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
184 
190  QPainter::CompositionMode blendMode() const { return mBlendMode; }
191 
192  protected:
193 
194  virtual void draw( QgsRenderContext& context ) override;
195 
196  private:
197 
198  double mTransparency;
199  QPainter::CompositionMode mBlendMode;
200  int mBrightness;
201  int mContrast;
202  double mSaturation;
203  QgsImageOperation::GrayscaleMode mGrayscaleMode;
204  bool mColorizeOn;
205  QColor mColorizeColor;
206  int mColorizeStrength;
207 };
208 
209 #endif // QGSBLUREFFECT_H
210 
virtual QgsStringMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
int contrast() const
Returns the contrast modification for the effect.
int colorizeStrength() const
Returns the strength used for colorizing a picture.
void setTransparency(const double transparency)
Sets the transparency for the effect.
Base class for visual effects which can be applied to QPicture drawings.
void setColorizeStrength(int colorizeStrength)
Sets the strength for colorizing a picture.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
void setGrayscaleMode(QgsImageOperation::GrayscaleMode grayscaleMode)
Sets whether the effect should convert a picture to grayscale.
void setBrightness(int brightness)
Sets the brightness modification for the effect.
virtual QString type() const override
Returns the effect type.
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.
double saturation() const
Returns the saturation modification for the effect.
void setColorizeOn(bool colorizeOn)
Sets whether the effect should colorize a picture.
void setContrast(int contrast)
Sets the contrast modification for the effect.
QColor colorizeColor() const
Returns the color used for colorizing a picture.
virtual void readProperties(const QgsStringMap &props)=0
Reads a string map of an effect's properties and restores the effect to the state described by the pr...
Contains information about the context of a rendering operation.
void setSaturation(double saturation)
Sets the saturation modification for the effect.
A paint effect which alters the colors (eg brightness, contrast) in a source picture.
bool colorizeOn() const
Returns whether the effect will colorize a picture.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect's result on to the specified render context.
GrayscaleMode
Modes for converting a QImage to grayscale.
double transparency() const
Returns the transparency for the effect.
QgsImageOperation::GrayscaleMode grayscaleMode() const
Returns whether the effect will convert a picture to grayscale.
int brightness() const
Returns the brightness modification for the effect.