QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgshuesaturationfilter.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgshuesaturationfilter.h
3  -------------------
4  begin : February 2013
5  copyright : (C) 2013 by Alexander Bruy, Nyall Dawson
6  email : alexander dot bruy 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 
18 #ifndef QGSHUESATURATIONFILTER_H
19 #define QGSHUESATURATIONFILTER_H
20 
21 #include "qgis_core.h"
22 #include "qgis_sip.h"
23 #include "qgsrasterinterface.h"
24 
25 class QDomElement;
26 
31 class CORE_EXPORT QgsHueSaturationFilter : public QgsRasterInterface
32 {
33  public:
34 
35  // Available modes for converting a raster to grayscale
37  {
41  GrayscaleAverage
42  };
43 
44  QgsHueSaturationFilter( QgsRasterInterface *input = nullptr );
45 
46  QgsHueSaturationFilter *clone() const override SIP_FACTORY;
47 
48  int bandCount() const override;
49 
50  Qgis::DataType dataType( int bandNo ) const override;
51 
52  bool setInput( QgsRasterInterface *input ) override;
53 
54  QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback = nullptr ) override SIP_FACTORY;
55 
56  void setSaturation( int saturation );
57  int saturation() const { return mSaturation; }
58 
64  void setInvertColors( bool invertColors ) { mInvertColors = invertColors; }
65 
70  bool invertColors() const { return mInvertColors; }
71 
72  void setGrayscaleMode( QgsHueSaturationFilter::GrayscaleMode grayscaleMode ) { mGrayscaleMode = grayscaleMode; }
73  QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const { return mGrayscaleMode; }
74 
75  void setColorizeOn( bool colorizeOn ) { mColorizeOn = colorizeOn; }
76  bool colorizeOn() const { return mColorizeOn; }
77  void setColorizeColor( const QColor &colorizeColor );
78  QColor colorizeColor() const { return mColorizeColor; }
79  void setColorizeStrength( int colorizeStrength ) { mColorizeStrength = colorizeStrength; }
80  int colorizeStrength() const { return mColorizeStrength; }
81 
82  void writeXml( QDomDocument &doc, QDomElement &parentElem ) const override;
83 
85  void readXml( const QDomElement &filterElem ) override;
86 
87  private:
89  void processSaturation( int &r, int &g, int &b, int &h, int &s, int &l );
91  void processColorization( int &r, int &g, int &b, int &h, int &s, int &l ) const;
92 
94  int mSaturation = 0;
95  double mSaturationScale = 1;
96 
99 
100  bool mInvertColors = false;
101 
103  bool mColorizeOn = false;
104  QColor mColorizeColor;
105  int mColorizeH = 0, mColorizeS = 50;
106  int mColorizeStrength = 100;
107 
108 };
109 
110 #endif // QGSHUESATURATIONFILTER_H
QgsHueSaturationFilter::GrayscaleLuminosity
@ GrayscaleLuminosity
Definition: qgshuesaturationfilter.h:40
QgsRasterInterface::writeXml
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Definition: qgsrasterinterface.h:494
QgsHueSaturationFilter::GrayscaleMode
GrayscaleMode
Definition: qgshuesaturationfilter.h:36
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
qgsrasterinterface.h
QgsHueSaturationFilter::grayscaleMode
QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const
Definition: qgshuesaturationfilter.h:73
QgsHueSaturationFilter::setGrayscaleMode
void setGrayscaleMode(QgsHueSaturationFilter::GrayscaleMode grayscaleMode)
Definition: qgshuesaturationfilter.h:72
QgsHueSaturationFilter::colorizeOn
bool colorizeOn() const
Definition: qgshuesaturationfilter.h:76
QgsHueSaturationFilter::setColorizeStrength
void setColorizeStrength(int colorizeStrength)
Definition: qgshuesaturationfilter.h:79
qgis_sip.h
QgsHueSaturationFilter::invertColors
bool invertColors() const
Returns true if the filter inverts colors.
Definition: qgshuesaturationfilter.h:70
QgsRasterInterface::clone
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
QgsHueSaturationFilter::colorizeColor
QColor colorizeColor() const
Definition: qgshuesaturationfilter.h:78
QgsHueSaturationFilter::setInvertColors
void setInvertColors(bool invertColors)
Sets whether the filter will invert colors.
Definition: qgshuesaturationfilter.h:64
QgsHueSaturationFilter
Color and saturation filter pipe for rasters.
Definition: qgshuesaturationfilter.h:31
QgsRasterInterface::readXml
virtual void readXml(const QDomElement &filterElem)
Sets base class members from xml. Usually called from create() methods of subclasses.
Definition: qgsrasterinterface.h:496
QgsHueSaturationFilter::colorizeStrength
int colorizeStrength() const
Definition: qgshuesaturationfilter.h:80
QgsRasterInterface
Base class for processing filters like renderers, reprojector, resampler etc.
Definition: qgsrasterinterface.h:135
QgsHueSaturationFilter::GrayscaleOff
@ GrayscaleOff
Definition: qgshuesaturationfilter.h:38
QgsRasterBlockFeedback
Feedback object tailored for raster block reading.
Definition: qgsrasterinterface.h:41
Qgis
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:71
QgsHueSaturationFilter::setColorizeOn
void setColorizeOn(bool colorizeOn)
Definition: qgshuesaturationfilter.h:75
QgsHueSaturationFilter::GrayscaleLightness
@ GrayscaleLightness
Definition: qgshuesaturationfilter.h:39
QgsRasterBlock
Raster data container.
Definition: qgsrasterblock.h:36