QGIS API Documentation 3.41.0-Master (3291e9ff48b)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsColorEffect Class Reference

A paint effect which alters the colors (e.g., brightness, contrast) in a source picture. More...

#include <qgscoloreffect.h>

Inheritance diagram for QgsColorEffect:
Inheritance graph
[legend]

Public Member Functions

 QgsColorEffect ()
 
QPainter::CompositionMode blendMode () const
 Returns the blend mode for the effect.
 
int brightness () const
 Returns the brightness modification for the effect.
 
QgsColorEffectclone () const override
 Duplicates an effect by creating a deep copy of the effect.
 
QColor colorizeColor () const
 Returns the color used for colorizing a picture.
 
bool colorizeOn () const
 Returns whether the effect will colorize a picture.
 
int colorizeStrength () const
 Returns the strength used for colorizing a picture.
 
int contrast () const
 Returns the contrast modification for the effect.
 
QgsImageOperation::GrayscaleMode grayscaleMode () const
 Returns whether the effect will convert a picture to grayscale.
 
double opacity () const
 Returns the opacity for the effect.
 
QVariantMap properties () const override
 Returns the properties describing the paint effect encoded in a string format.
 
void readProperties (const QVariantMap &props) override
 Reads a string map of an effect's properties and restores the effect to the state described by the properties map.
 
double saturation () const
 Returns the saturation modification for the effect.
 
void setBlendMode (const QPainter::CompositionMode mode)
 Sets the blend mode for the effect.
 
void setBrightness (int brightness)
 Sets the brightness modification for the effect.
 
void setColorizeColor (const QColor &colorizeColor)
 Sets the color used for colorizing a picture.
 
void setColorizeOn (bool colorizeOn)
 Sets whether the effect should colorize a picture.
 
void setColorizeStrength (int colorizeStrength)
 Sets the strength for colorizing a picture.
 
void setContrast (int contrast)
 Sets the contrast modification for the effect.
 
void setGrayscaleMode (QgsImageOperation::GrayscaleMode grayscaleMode)
 Sets whether the effect should convert a picture to grayscale.
 
void setOpacity (const double opacity)
 Sets the opacity for the effect.
 
void setSaturation (double saturation)
 Sets the saturation modification for the effect.
 
QString type () const override
 Returns the effect type.
 
- Public Member Functions inherited from QgsPaintEffect
 QgsPaintEffect ()=default
 
 QgsPaintEffect (const QgsPaintEffect &other)
 
virtual ~QgsPaintEffect ()
 
virtual void begin (QgsRenderContext &context)
 Begins intercepting paint operations to a render context.
 
DrawMode drawMode () const
 Returns the draw mode for the effect.
 
bool enabled () const
 Returns whether the effect is enabled.
 
virtual void end (QgsRenderContext &context)
 Ends interception of paint operations to a render context, and draws the result to the render context after being modified by the effect.
 
virtual bool readProperties (const QDomElement &element)
 Restores the effect to the state described by a DOM element.
 
virtual void render (QPicture &picture, QgsRenderContext &context)
 Renders a picture using the effect.
 
virtual bool saveProperties (QDomDocument &doc, QDomElement &element) const
 Saves the current state of the effect to a DOM element.
 
void setDrawMode (DrawMode drawMode)
 Sets the draw mode for the effect.
 
void setEnabled (bool enabled)
 Sets whether the effect is enabled.
 

Static Public Member Functions

static QgsPaintEffectcreate (const QVariantMap &map)
 Creates a new QgsColorEffect effect from a properties string map.
 

Protected Member Functions

void draw (QgsRenderContext &context) override
 Handles drawing of the effect's result on to the specified render context.
 
- Protected Member Functions inherited from QgsPaintEffect
virtual QRectF boundingRect (const QRectF &rect, const QgsRenderContext &context) const
 Returns the bounding rect required for drawing the effect.
 
void drawSource (QPainter &painter)
 Draws the source QPicture onto the specified painter.
 
Q_DECL_DEPRECATED void fixQPictureDpi (QPainter *painter) const
 Applies a workaround to a QPainter to avoid an issue with incorrect scaling when drawing QPictures.
 
QPointF imageOffset (const QgsRenderContext &context) const
 Returns the offset which should be used when drawing the source image on to a destination render context.
 
const QPicture * source () const
 Returns the source QPicture.
 
QImage * sourceAsImage (QgsRenderContext &context)
 Returns the source QPicture rendered to a new QImage.
 

Additional Inherited Members

- Public Types inherited from QgsPaintEffect
enum  DrawMode { Modifier , Render , ModifyAndRender }
 Drawing modes for effects. More...
 
- Protected Attributes inherited from QgsPaintEffect
DrawMode mDrawMode = ModifyAndRender
 
bool mEnabled = true
 
bool requiresQPainterDpiFix = true
 

Detailed Description

A paint effect which alters the colors (e.g., brightness, contrast) in a source picture.

Definition at line 34 of file qgscoloreffect.h.

Constructor & Destructor Documentation

◆ QgsColorEffect()

QgsColorEffect::QgsColorEffect ( )

Definition at line 32 of file qgscoloreffect.cpp.

Member Function Documentation

◆ blendMode()

QPainter::CompositionMode QgsColorEffect::blendMode ( ) const
inline

Returns the blend mode for the effect.

Returns
blend mode used for drawing the effect on to a destination paint device
See also
setBlendMode

Definition at line 209 of file qgscoloreffect.h.

◆ brightness()

int QgsColorEffect::brightness ( ) const
inline

Returns the brightness modification for the effect.

Returns
brightness value. Values are between -255 and 255, where 0 represents no change, negative values indicate darkening and positive values indicate lightening
See also
setBrightness

Definition at line 69 of file qgscoloreffect.h.

◆ clone()

QgsColorEffect * QgsColorEffect::clone ( ) const
overridevirtual

Duplicates an effect by creating a deep copy of the effect.

Returns
clone of paint effect

Implements QgsPaintEffect.

Definition at line 134 of file qgscoloreffect.cpp.

◆ colorizeColor()

QColor QgsColorEffect::colorizeColor ( ) const
inline

Returns the color used for colorizing a picture.

This is only used if colorizeOn() is set to true.

Returns
colorization color
See also
setColorizeColor
colorizeOn
colorizeStrength

Definition at line 157 of file qgscoloreffect.h.

◆ colorizeOn()

bool QgsColorEffect::colorizeOn ( ) const
inline

Returns whether the effect will colorize a picture.

Returns
true if colorization is enabled
See also
setColorizeOn
colorizeColor
colorizeStrength

Definition at line 137 of file qgscoloreffect.h.

◆ colorizeStrength()

int QgsColorEffect::colorizeStrength ( ) const
inline

Returns the strength used for colorizing a picture.

This is only used if setColorizeOn() is set to true.

Returns
colorization strength, between 0 and 100
See also
setColorizeStrength
colorizeOn
colorizeColor

Definition at line 177 of file qgscoloreffect.h.

◆ contrast()

int QgsColorEffect::contrast ( ) const
inline

Returns the contrast modification for the effect.

Returns
contrast value. Values are between -100 and 100, where 0 represents no change, negative values indicate less contrast and positive values indicate greater contrast
See also
setContrast

Definition at line 87 of file qgscoloreffect.h.

◆ create()

QgsPaintEffect * QgsColorEffect::create ( const QVariantMap &  map)
static

Creates a new QgsColorEffect effect from a properties string map.

Parameters
mapencoded properties string map
Returns
new QgsColorEffect

Definition at line 25 of file qgscoloreffect.cpp.

◆ draw()

void QgsColorEffect::draw ( QgsRenderContext context)
overrideprotectedvirtual

Handles drawing of the effect's result on to the specified 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.

Parameters
contextdestination render context
See also
drawSource

Implements QgsPaintEffect.

Definition at line 38 of file qgscoloreffect.cpp.

◆ grayscaleMode()

QgsImageOperation::GrayscaleMode QgsColorEffect::grayscaleMode ( ) const
inline

Returns whether the effect will convert a picture to grayscale.

Returns
method for grayscale conversion
See also
setGrayscaleMode

Definition at line 119 of file qgscoloreffect.h.

◆ opacity()

double QgsColorEffect::opacity ( ) const
inline

Returns the opacity for the effect.

Returns
opacity value between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque.
See also
setOpacity()

Definition at line 193 of file qgscoloreffect.h.

◆ properties()

QVariantMap QgsColorEffect::properties ( ) const
overridevirtual

Returns the properties describing the paint effect encoded in a string format.

Returns
string map of properties, in the form property key, value
See also
readProperties
saveProperties

Implements QgsPaintEffect.

Definition at line 77 of file qgscoloreffect.cpp.

◆ readProperties()

void QgsColorEffect::readProperties ( const QVariantMap &  props)
overridevirtual

Reads a string map of an effect's properties and restores the effect to the state described by the properties map.

Parameters
propseffect properties encoded in a string map
See also
properties

Implements QgsPaintEffect.

Definition at line 95 of file qgscoloreffect.cpp.

◆ saturation()

double QgsColorEffect::saturation ( ) const
inline

Returns the saturation modification for the effect.

Returns
saturation value. Values are between 0 and 2.0, where 1.0 represents no change, 0.0 represents totally desaturated (grayscale), and positive values indicate greater saturation
See also
setSaturation

Definition at line 105 of file qgscoloreffect.h.

◆ setBlendMode()

void QgsColorEffect::setBlendMode ( const QPainter::CompositionMode  mode)
inline

Sets the blend mode for the effect.

Parameters
modeblend mode used for drawing the effect on to a destination paint device
See also
blendMode

Definition at line 201 of file qgscoloreffect.h.

◆ setBrightness()

void QgsColorEffect::setBrightness ( int  brightness)

Sets the brightness modification for the effect.

Parameters
brightnessValid values are between -255 and 255, where 0 represents no change, negative values indicate darkening and positive values indicate lightening
See also
setBrightness

Definition at line 140 of file qgscoloreffect.cpp.

◆ setColorizeColor()

void QgsColorEffect::setColorizeColor ( const QColor &  colorizeColor)

Sets the color used for colorizing a picture.

This is only used if setColorizeOn() is set to true.

Parameters
colorizeColorcolorization color
See also
colorizeColor
setColorizeOn
setColorizeStrength

Definition at line 150 of file qgscoloreffect.cpp.

◆ setColorizeOn()

void QgsColorEffect::setColorizeOn ( bool  colorizeOn)
inline

Sets whether the effect should colorize a picture.

Parameters
colorizeOnset to true to enable colorization
See also
colorizeOn
setColorizeColor
setColorizeStrength

Definition at line 128 of file qgscoloreffect.h.

◆ setColorizeStrength()

void QgsColorEffect::setColorizeStrength ( int  colorizeStrength)
inline

Sets the strength for colorizing a picture.

This is only used if setColorizeOn() is set to true.

Parameters
colorizeStrengthcolorization strength, between 0 and 100
See also
colorizeStrength
setColorizeOn
setColorizeColor

Definition at line 167 of file qgscoloreffect.h.

◆ setContrast()

void QgsColorEffect::setContrast ( int  contrast)

Sets the contrast modification for the effect.

Parameters
contrastValid values are between -100 and 100, where 0 represents no change, negative values indicate less contrast and positive values indicate greater contrast
See also
setContrast

Definition at line 145 of file qgscoloreffect.cpp.

◆ setGrayscaleMode()

void QgsColorEffect::setGrayscaleMode ( QgsImageOperation::GrayscaleMode  grayscaleMode)
inline

Sets whether the effect should convert a picture to grayscale.

Parameters
grayscaleModemethod for grayscale conversion
See also
grayscaleMode

Definition at line 112 of file qgscoloreffect.h.

◆ setOpacity()

void QgsColorEffect::setOpacity ( const double  opacity)
inline

Sets the opacity for the effect.

Parameters
opacitydouble between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque
See also
opacity()

Definition at line 185 of file qgscoloreffect.h.

◆ setSaturation()

void QgsColorEffect::setSaturation ( double  saturation)
inline

Sets the saturation modification for the effect.

Parameters
saturationValid values are between 0 and 2.0, where 1.0 represents no change, 0.0 represents totally desaturated (grayscale), and positive values indicate greater saturation
See also
saturation

Definition at line 96 of file qgscoloreffect.h.

◆ type()

QString QgsColorEffect::type ( ) const
inlineoverridevirtual

Returns the effect type.

Returns
unique string representation of the effect type

Implements QgsPaintEffect.

Definition at line 48 of file qgscoloreffect.h.


The documentation for this class was generated from the following files: