QGIS API Documentation  2.99.0-Master (e077efd)
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 "qgsrasterinterface.h"
22 
23 class QDomElement;
24 
28 class CORE_EXPORT QgsHueSaturationFilter : public QgsRasterInterface
29 {
30  public:
31 
32  // Available modes for converting a raster to grayscale
34  {
38  GrayscaleAverage
39  };
40 
41  QgsHueSaturationFilter( QgsRasterInterface *input = nullptr );
43 
44  QgsHueSaturationFilter * clone() const override;
45 
46  int bandCount() const override;
47 
48  Qgis::DataType dataType( int bandNo ) const override;
49 
50  bool setInput( QgsRasterInterface* input ) override;
51 
52  QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr ) override;
53 
54  void setSaturation( int saturation );
55  int saturation() const { return mSaturation; }
56 
57  void setGrayscaleMode( QgsHueSaturationFilter::GrayscaleMode grayscaleMode ) { mGrayscaleMode = grayscaleMode; }
58  QgsHueSaturationFilter::GrayscaleMode grayscaleMode() const { return mGrayscaleMode; }
59 
60  void setColorizeOn( bool colorizeOn ) { mColorizeOn = colorizeOn; }
61  bool colorizeOn() const { return mColorizeOn; }
62  void setColorizeColor( const QColor& colorizeColor );
63  QColor colorizeColor() const { return mColorizeColor; }
64  void setColorizeStrength( int colorizeStrength ) { mColorizeStrength = colorizeStrength; }
65  int colorizeStrength() const { return mColorizeStrength; }
66 
67  void writeXml( QDomDocument& doc, QDomElement& parentElem ) const override;
68 
70  void readXml( const QDomElement& filterElem ) override;
71 
72  private:
74  void processSaturation( int &r, int &g, int &b, int &h, int &s, int &l );
76  void processColorization( int &r, int &g, int &b, int &h, int &s, int &l );
77 
79  int mSaturation;
80  double mSaturationScale;
81 
84 
86  bool mColorizeOn;
87  QColor mColorizeColor;
88  int mColorizeH, mColorizeS;
89  int mColorizeStrength;
90 
91 };
92 
93 #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. Usually called from create() methods of subclasses.
DataType
Raster data types.
Definition: qgis.h:60
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
Raster data container.
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr)=0
Read block of data using given extent and size.
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.
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)