QGIS API Documentation  2.99.0-Master (c558d51)
qgsbrightnesscontrastfilter.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsbrightnesscontrastfilter.h
3  -------------------
4  begin : February 2013
5  copyright : (C) 2013 by Alexander Bruy
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 QGSBRIGHTNESSCONTRASTFILTER_H
19 #define QGSBRIGHTNESSCONTRASTFILTER_H
20 
21 #include "qgsrasterinterface.h"
22 
23 class QDomElement;
24 
29 {
30  public:
33 
34  QgsBrightnessContrastFilter* clone() const override;
35 
36  int bandCount() const override;
37 
38  Qgis::DataType dataType( int bandNo ) const override;
39 
40  bool setInput( QgsRasterInterface* input ) override;
41 
42  QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback* feedback = nullptr ) override;
43 
44  void setBrightness( int brightness ) { mBrightness = qBound( -255, brightness, 255 ); }
45  int brightness() const { return mBrightness; }
46 
47  void setContrast( int contrast ) { mContrast = qBound( -100, contrast, 100 ); }
48  int contrast() const { return mContrast; }
49 
50  void writeXml( QDomDocument& doc, QDomElement& parentElem ) const override;
51 
53  void readXml( const QDomElement& filterElem ) override;
54 
55  private:
57  int adjustColorComponent( int colorComponent, int alpha, int brightness, double contrastFactor ) const;
58 
60  int mBrightness;
61 
63  double mContrast;
64 };
65 
66 #endif // QGSBRIGHTNESSCONTRASTFILTER_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.
virtual void writeXml(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
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.
Brightness/contrast filter pipe for rasters.
Feedback object tailored for raster block reading.