QGIS API Documentation  2.14.0-Essen
qgsblureffect.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsblureffect.h
3  ---------------
4  begin : December 2014
5  copyright : (C) 2014 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 QGSBLUREFFECT_H
18 #define QGSBLUREFFECT_H
19 
20 #include "qgspainteffect.h"
21 #include "qgis.h"
22 #include <QPainter>
23 
32 class CORE_EXPORT QgsBlurEffect : public QgsPaintEffect
33 {
34 
35  public:
36 
39  {
41  GaussianBlur
42  };
43 
48  static QgsPaintEffect* create( const QgsStringMap& map );
49 
50  QgsBlurEffect();
51  virtual ~QgsBlurEffect();
52 
53  virtual QString type() const override { return QString( "blur" ); }
54  virtual QgsStringMap properties() const override;
55  virtual void readProperties( const QgsStringMap& props ) override;
56  virtual QgsBlurEffect* clone() const override;
57 
64  void setBlurLevel( const int level ) { mBlurLevel = level; }
65 
72  int blurLevel() const { return mBlurLevel; }
73 
78  void setBlurMethod( const BlurMethod method ) { mBlurMethod = method; }
79 
84  BlurMethod blurMethod() const { return mBlurMethod; }
85 
91  void setTransparency( const double transparency ) { mTransparency = transparency; }
92 
98  double transparency() const { return mTransparency; }
99 
105  void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
106 
112  QPainter::CompositionMode blendMode() const { return mBlendMode; }
113 
114  protected:
115 
116  virtual void draw( QgsRenderContext& context ) override;
117  virtual QRectF boundingRect( const QRectF& rect, const QgsRenderContext& context ) const override;
118 
119  private:
120 
121  int mBlurLevel;
122  BlurMethod mBlurMethod;
123  double mTransparency;
124  QPainter::CompositionMode mBlendMode;
125 
126  void drawStackBlur( QgsRenderContext &context );
127  void drawGaussianBlur( QgsRenderContext &context );
128  void drawBlurredImage( QgsRenderContext& context, QImage &image );
129 };
130 
131 #endif // QGSBLUREFFECT_H
132 
void setBlurMethod(const BlurMethod method)
Sets the blur method (algorithm) to use for performing the blur.
Definition: qgsblureffect.h:78
virtual QgsStringMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
virtual QRectF boundingRect(const QRectF &rect, const QgsRenderContext &context) const
Returns the bounding rect required for drawing the effect.
Base class for visual effects which can be applied to QPicture drawings.
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.
void setBlurLevel(const int level)
Sets blur level (strength)
Definition: qgsblureffect.h:64
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
BlurMethod
Available blur methods (algorithms)
Definition: qgsblureffect.h:38
BlurMethod blurMethod() const
Returns the blur method (algorithm) used for performing the blur.
Definition: qgsblureffect.h:84
double transparency() const
Returns the transparency for the effect.
Definition: qgsblureffect.h:98
A paint effect which blurs a source picture, using a number of different blur methods.
Definition: qgsblureffect.h:32
virtual QString type() const override
Returns the effect type.
Definition: qgsblureffect.h:53
virtual void readProperties(const QgsStringMap &props)=0
Reads a string map of an effect&#39;s properties and restores the effect to the state described by the pr...
Contains information about the context of a rendering operation.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect&#39;s result on to the specified render context.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
void setTransparency(const double transparency)
Sets the transparency for the effect.
Definition: qgsblureffect.h:91
int blurLevel() const
Returns the blur level (strength)
Definition: qgsblureffect.h:72