QGIS API Documentation  3.6.0-Noosa (5873452)
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
A rectangle specified with double values.
Definition: qgsrectangle.h:41
virtual void readXml(const QDomElement &filterElem)
Sets base class members from xml. Usually called from create() methods of subclasses.
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:45
Raster data container.
#define SIP_FACTORY
Definition: qgis_sip.h:69
void setColorizeOn(bool colorizeOn)
Base class for processing filters like renderers, reprojector, resampler etc.
QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
Color and saturation filter pipe for rasters.
void setColorizeStrength(int colorizeStrength)
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
Feedback object tailored for raster block reading.
void setGrayscaleMode(QgsHueSaturationFilter::GrayscaleMode grayscaleMode)