QGIS API Documentation  2.14.0-Essen
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 "qgsrasterdataprovider.h"
22 #include "qgsrasterinterface.h"
23 
24 class QDomElement;
25 
29 class CORE_EXPORT QgsHueSaturationFilter : public QgsRasterInterface
30 {
31  public:
32 
33  // Available modes for converting a raster to grayscale
35  {
39  GrayscaleAverage
40  };
41 
42  QgsHueSaturationFilter( QgsRasterInterface *input = nullptr );
44 
45  QgsHueSaturationFilter * clone() const override;
46 
47  int bandCount() const override;
48 
49  QGis::DataType dataType( int bandNo ) const override;
50 
51  bool setInput( QgsRasterInterface* input ) override;
52 
53  QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) override;
54 
55  void setSaturation( int saturation );
56  int saturation() const { return mSaturation; }
57 
58  void setGrayscaleMode( QgsHueSaturationFilter::GrayscaleMode grayscaleMode ) { mGrayscaleMode = grayscaleMode; }
59  QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const { return mGrayscaleMode; }
60 
61  void setColorizeOn( bool colorizeOn ) { mColorizeOn = colorizeOn; }
62  bool colorizeOn() const { return mColorizeOn; }
63  void setColorizeColor( const QColor& colorizeColor );
64  QColor colorizeColor() const { return mColorizeColor; }
65  void setColorizeStrength( int colorizeStrength ) { mColorizeStrength = colorizeStrength; }
66  int colorizeStrength() const { return mColorizeStrength; }
67 
68  void writeXML( QDomDocument& doc, QDomElement& parentElem ) const override;
69 
71  void readXML( const QDomElement& filterElem ) override;
72 
73  private:
75  void processSaturation( int &r, int &g, int &b, int &h, int &s, int &l );
77  void processColorization( int &r, int &g, int &b, int &h, int &s, int &l );
78 
80  int mSaturation;
81  double mSaturationScale;
82 
85 
87  bool mColorizeOn;
88  QColor mColorizeColor;
89  int mColorizeH, mColorizeS;
90  int mColorizeStrength;
91 
92 };
93 
94 #endif // QGSHUESATURATIONFILTER_H
virtual int bandCount() const =0
Get number of bands.
A rectangle specified with double values.
Definition: qgsrectangle.h:35
virtual void readXML(const QDomElement &filterElem)
Sets base class members from xml.
Raster data container.
QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const
virtual void writeXML(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
virtual QGis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
void setColorizeOn(bool colorizeOn)
Base class for processing filters like renderers, reprojector, resampler etc.
virtual bool setInput(QgsRasterInterface *input)
Set input.
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
Color and saturation filter pipe for rasters.
DataType
Raster data types.
Definition: qgis.h:129
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height)=0
Read block of data using given extent and size.
void setColorizeStrength(int colorizeStrength)
void setGrayscaleMode(QgsHueSaturationFilter::GrayscaleMode grayscaleMode)