QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
59  void setGrayscaleMode( QgsHueSaturationFilter::GrayscaleMode grayscaleMode ) { mGrayscaleMode = grayscaleMode; }
60  QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const { return mGrayscaleMode; }
61 
62  void setColorizeOn( bool colorizeOn ) { mColorizeOn = colorizeOn; }
63  bool colorizeOn() const { return mColorizeOn; }
64  void setColorizeColor( const QColor &colorizeColor );
65  QColor colorizeColor() const { return mColorizeColor; }
66  void setColorizeStrength( int colorizeStrength ) { mColorizeStrength = colorizeStrength; }
67  int colorizeStrength() const { return mColorizeStrength; }
68 
69  void writeXml( QDomDocument &doc, QDomElement &parentElem ) const override;
70 
72  void readXml( const QDomElement &filterElem ) override;
73 
74  private:
76  void processSaturation( int &r, int &g, int &b, int &h, int &s, int &l );
78  void processColorization( int &r, int &g, int &b, int &h, int &s, int &l );
79 
81  int mSaturation = 0;
82  double mSaturationScale = 1;
83 
86 
88  bool mColorizeOn = false;
89  QColor mColorizeColor;
90  int mColorizeH = 0, mColorizeS = 50;
91  int mColorizeStrength = 100;
92 
93 };
94 
95 #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:461
QgsHueSaturationFilter::GrayscaleMode
GrayscaleMode
Definition: qgshuesaturationfilter.h:36
QgsRectangle
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:60
QgsHueSaturationFilter::setGrayscaleMode
void setGrayscaleMode(QgsHueSaturationFilter::GrayscaleMode grayscaleMode)
Definition: qgshuesaturationfilter.h:59
QgsHueSaturationFilter::colorizeOn
bool colorizeOn() const
Definition: qgshuesaturationfilter.h:63
QgsHueSaturationFilter::setColorizeStrength
void setColorizeStrength(int colorizeStrength)
Definition: qgshuesaturationfilter.h:66
qgis_sip.h
QgsRasterInterface::clone
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
QgsHueSaturationFilter::colorizeColor
QColor colorizeColor() const
Definition: qgshuesaturationfilter.h:65
QgsHueSaturationFilter
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:463
QgsHueSaturationFilter::colorizeStrength
int colorizeStrength() const
Definition: qgshuesaturationfilter.h:67
QgsRasterInterface
Definition: qgsrasterinterface.h:116
QgsHueSaturationFilter::GrayscaleOff
@ GrayscaleOff
Definition: qgshuesaturationfilter.h:38
QgsRasterBlockFeedback
Definition: qgsrasterinterface.h:40
Qgis
Definition: qgis.h:45
QgsHueSaturationFilter::setColorizeOn
void setColorizeOn(bool colorizeOn)
Definition: qgshuesaturationfilter.h:62
QgsHueSaturationFilter::GrayscaleLightness
@ GrayscaleLightness
Definition: qgshuesaturationfilter.h:39
QgsRasterBlock
Definition: qgsrasterblock.h:36