QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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  QgsRasterBlock *block2( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr ) override;
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;
82  double mSaturationScale;
83 
86 
88  bool mColorizeOn;
89  QColor mColorizeColor;
90  int mColorizeH, mColorizeS;
91  int mColorizeStrength;
92 
93 };
94 
95 #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.
virtual QgsRasterBlock * block2(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)
Read block of data using given extent and size.
Raster data container.
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.
QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const
virtual QgsRasterInterface * clone() const =0
Clone itself, create deep copy.
Color and saturation filter pipe for rasters.
DataType
Raster data types.
Definition: qgis.h:133
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)
Feedback object tailored for raster block reading.
void setGrayscaleMode(QgsHueSaturationFilter::GrayscaleMode grayscaleMode)