QgsBlurEffect class
A paint effect which blurs a source picture, using a number of different blur methods.
Contents
Base classes
- class QgsPaintEffect
- Base class for visual effects which can be applied to QPicture drawings.
Public types
- enum BlurMethod { StackBlur, GaussianBlur }
- Available blur methods (algorithms)
Public static functions
- static auto create(const QgsStringMap& map) -> QgsPaintEffect*
- Creates a new QgsBlurEffect effect from a properties string map.
Constructors, destructors, conversion operators
- QgsBlurEffect() defaulted
- Constructor for QgsBlurEffect.
Public functions
- auto blendMode() const -> QPainter::CompositionMode
- Returns the blend mode for the effect.
- auto blurLevel() const -> int
- Returns the blur level (strength)
- auto blurMethod() const -> BlurMethod
- Returns the blur method (algorithm) used for performing the blur.
- auto clone() const -> QgsBlurEffect* override
- Duplicates an effect by creating a deep copy of the effect.
- auto opacity() const -> double
- Returns the opacity for the effect.
- auto properties() const -> QgsStringMap override
- Returns the properties describing the paint effect encoded in a string format.
- void readProperties(const QgsStringMap& props) override
- Reads a string map of an effect's properties and restores the effect to the state described by the properties map.
- void setBlendMode(const QPainter::CompositionMode mode)
- Sets the blend mode for the effect.
- void setBlurLevel(const int level)
- Sets blur level (strength)
- void setBlurMethod(const BlurMethod method)
- Sets the blur method (algorithm) to use for performing the blur.
- void setOpacity(const double opacity)
- Sets the opacity for the effect.
- auto type() const -> QString override
- Returns the effect type.
Protected functions
- auto boundingRect(const QRectF& rect, const QgsRenderContext& context) const -> QRectF override
- Returns the bounding rect required for drawing the effect.
- void draw(QgsRenderContext& context) override
- Handles drawing of the effect's result on to the specified render context.
Enum documentation
enum QgsBlurEffect:: BlurMethod
Available blur methods (algorithms)
| Enumerators | |
|---|---|
| StackBlur |
Stack blur, a fast but low quality blur. Valid blur level values are between 0 - 16. |
| GaussianBlur |
Gaussian blur, a slower but high quality blur. Blur level values are the distance in pixels for the blur operation. |
Function documentation
static QgsPaintEffect* QgsBlurEffect:: create(const QgsStringMap& map)
Creates a new QgsBlurEffect effect from a properties string map.
| Parameters | |
|---|---|
| map | encoded properties string map |
| Returns | new QgsBlurEffect |
QPainter::CompositionMode QgsBlurEffect:: blendMode() const
Returns the blend mode for the effect.
| Returns | blend mode used for drawing the effect on to a destination paint device |
|---|
int QgsBlurEffect:: blurLevel() const
Returns the blur level (strength)
| Returns | blur level. Depending on the current blurMethod(), this parameter has different effects |
|---|
BlurMethod QgsBlurEffect:: blurMethod() const
Returns the blur method (algorithm) used for performing the blur.
| Returns | blur method |
|---|
QgsBlurEffect* QgsBlurEffect:: clone() const override
Duplicates an effect by creating a deep copy of the effect.
| Returns | clone of paint effect |
|---|
double QgsBlurEffect:: opacity() const
Returns the opacity for the effect.
| Returns | opacity value between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque |
|---|
QgsStringMap QgsBlurEffect:: properties() const override
Returns the properties describing the paint effect encoded in a string format.
| Returns | string map of properties, in the form property key, value |
|---|
void QgsBlurEffect:: readProperties(const QgsStringMap& props) override
Reads a string map of an effect's properties and restores the effect to the state described by the properties map.
| Parameters | |
|---|---|
| props | effect properties encoded in a string map |
void QgsBlurEffect:: setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
| Parameters | |
|---|---|
| mode | blend mode used for drawing the effect on to a destination paint device |
void QgsBlurEffect:: setBlurLevel(const int level)
Sets blur level (strength)
| Parameters | |
|---|---|
| level | blur level. Depending on the current blurMethod(), this parameter has different effects |
void QgsBlurEffect:: setBlurMethod(const BlurMethod method)
Sets the blur method (algorithm) to use for performing the blur.
| Parameters | |
|---|---|
| method | blur method |
void QgsBlurEffect:: setOpacity(const double opacity)
Sets the opacity for the effect.
| Parameters | |
|---|---|
| opacity | double between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque |
QString QgsBlurEffect:: type() const override
Returns the effect type.
| Returns | unique string representation of the effect type |
|---|
QRectF QgsBlurEffect:: boundingRect(const QRectF& rect,
const QgsRenderContext& context) const override protected
Returns the bounding rect required for drawing the effect.
| Parameters | |
|---|---|
| rect | original source bounding rect |
| context | destination render context |
| Returns | modified bounding rect |
This method can be used to expand the bounding rect of a source picture to account for offset or blurring effects.
void QgsBlurEffect:: draw(QgsRenderContext& context) override protected
Handles drawing of the effect's result on to the specified render context.
| Parameters | |
|---|---|
| context | destination render context |
Derived classes must reimplement this method to apply any transformations to the source QPicture and draw the result using the context's painter.