QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
QgsRasterTransparency Class Reference

Defines the list of pixel values to be considered as transparent or semi transparent when rendering rasters. More...

#include <qgsrastertransparency.h>

Classes

struct  TransparentSingleValuePixel
 Defines the transparency for a range of single-band pixel values. More...
 
struct  TransparentThreeValuePixel
 Defines the transparency for a RGB pixel value. More...
 

Public Member Functions

 QgsRasterTransparency ()=default
 
Q_DECL_DEPRECATED int alphaValue (double redValue, double greenValue, double blueValue, int globalTransparency=255) const
 Returns the transparency value for a RGB pixel.
 
Q_DECL_DEPRECATED int alphaValue (double value, int globalTransparency=255) const
 Returns the transparency value for a single value pixel.
 
void initializeTransparentPixelList (double redValue, double greenValue, double blueValue)
 Resets the transparency list to single red, green, and blue values.
 
void initializeTransparentPixelList (double value)
 Resets the transparency list to a single value.
 
bool isEmpty () const
 True if there are no entries in the pixel lists except the nodata value.
 
double opacityForRgbValues (double redValue, double greenValue, double blueValue) const
 Returns the opacity (as a value from 0 to 1) for a set of RGB pixel values.
 
double opacityForValue (double value) const
 Returns the opacity (as a value from 0 to 1) for a single value pixel.
 
void readXml (const QDomElement &elem)
 Reads the transparency information from an XML document.
 
void setTransparentSingleValuePixelList (const QVector< QgsRasterTransparency::TransparentSingleValuePixel > &newList)
 Sets the transparent single value pixel list, replacing the whole existing list.
 
void setTransparentThreeValuePixelList (const QVector< QgsRasterTransparency::TransparentThreeValuePixel > &newList)
 Sets the transparent three value pixel list, replacing the whole existing list.
 
QVector< QgsRasterTransparency::TransparentSingleValuePixeltransparentSingleValuePixelList () const
 Returns the transparent single value pixel list.
 
QVector< QgsRasterTransparency::TransparentThreeValuePixeltransparentThreeValuePixelList () const
 Returns the transparent three value pixel list.
 
void writeXml (QDomDocument &doc, QDomElement &parentElem) const
 Writes the transparency information to an XML document.
 

Detailed Description

Defines the list of pixel values to be considered as transparent or semi transparent when rendering rasters.

Definition at line 33 of file qgsrastertransparency.h.

Constructor & Destructor Documentation

◆ QgsRasterTransparency()

QgsRasterTransparency::QgsRasterTransparency ( )
default

Member Function Documentation

◆ alphaValue() [1/2]

int QgsRasterTransparency::alphaValue ( double  redValue,
double  greenValue,
double  blueValue,
int  globalTransparency = 255 
) const

Returns the transparency value for a RGB pixel.

Searches through the transparency list, if a match is found, the global transparency value is scaled by the stored transparency value.

Parameters
redValuethe red portion of the needle to search for in the transparency hay stack
greenValuethe green portion of the needle to search for in the transparency hay stack
blueValuethe green portion of the needle to search for in the transparency hay stack
globalTransparencythe overall transparency level for the layer
Deprecated:
QGIS 3.40. Use opacityForRgbValues() instead.

Definition at line 93 of file qgsrastertransparency.cpp.

◆ alphaValue() [2/2]

int QgsRasterTransparency::alphaValue ( double  value,
int  globalTransparency = 255 
) const

Returns the transparency value for a single value pixel.

Searches through the transparency list, and if a match is found, the global transparency value is scaled by the stored transparency value.

Parameters
valuethe needle to search for in the transparency hay stack
globalTransparencythe overall transparency level for the layer
Deprecated:
QGIS 3.40. Use opacityForValue() instead.

Definition at line 64 of file qgsrastertransparency.cpp.

◆ initializeTransparentPixelList() [1/2]

void QgsRasterTransparency::initializeTransparentPixelList ( double  redValue,
double  greenValue,
double  blueValue 
)

Resets the transparency list to single red, green, and blue values.

Definition at line 45 of file qgsrastertransparency.cpp.

◆ initializeTransparentPixelList() [2/2]

void QgsRasterTransparency::initializeTransparentPixelList ( double  value)

Resets the transparency list to a single value.

Definition at line 36 of file qgsrastertransparency.cpp.

◆ isEmpty()

bool QgsRasterTransparency::isEmpty ( ) const

True if there are no entries in the pixel lists except the nodata value.

Definition at line 122 of file qgsrastertransparency.cpp.

◆ opacityForRgbValues()

double QgsRasterTransparency::opacityForRgbValues ( double  redValue,
double  greenValue,
double  blueValue 
) const

Returns the opacity (as a value from 0 to 1) for a set of RGB pixel values.

Searches through the transparency list, and if a match is found, returns the opacity corresponding to the values. Returns 1 if no matches are found.

If any of the red, green or blue values are NaN, 0 will be returned.

Since
QGIS 3.38

Definition at line 98 of file qgsrastertransparency.cpp.

◆ opacityForValue()

double QgsRasterTransparency::opacityForValue ( double  value) const

Returns the opacity (as a value from 0 to 1) for a single value pixel.

Searches through the transparency list, and if a match is found, returns the opacity corresponding to the value. Returns 1 if no matches are found.

Since
QGIS 3.38

Definition at line 69 of file qgsrastertransparency.cpp.

◆ readXml()

void QgsRasterTransparency::readXml ( const QDomElement &  elem)

Reads the transparency information from an XML document.

Definition at line 169 of file qgsrastertransparency.cpp.

◆ setTransparentSingleValuePixelList()

void QgsRasterTransparency::setTransparentSingleValuePixelList ( const QVector< QgsRasterTransparency::TransparentSingleValuePixel > &  newList)

Sets the transparent single value pixel list, replacing the whole existing list.

See also
transparentSingleValuePixelList()

Definition at line 54 of file qgsrastertransparency.cpp.

◆ setTransparentThreeValuePixelList()

void QgsRasterTransparency::setTransparentThreeValuePixelList ( const QVector< QgsRasterTransparency::TransparentThreeValuePixel > &  newList)

Sets the transparent three value pixel list, replacing the whole existing list.

See also
transparentThreeValuePixelList()

Definition at line 59 of file qgsrastertransparency.cpp.

◆ transparentSingleValuePixelList()

QVector< QgsRasterTransparency::TransparentSingleValuePixel > QgsRasterTransparency::transparentSingleValuePixelList ( ) const

Returns the transparent single value pixel list.

See also
setTransparentSingleValuePixelList()

Definition at line 26 of file qgsrastertransparency.cpp.

◆ transparentThreeValuePixelList()

QVector< QgsRasterTransparency::TransparentThreeValuePixel > QgsRasterTransparency::transparentThreeValuePixelList ( ) const

Returns the transparent three value pixel list.

See also
setTransparentThreeValuePixelList()

Definition at line 31 of file qgsrastertransparency.cpp.

◆ writeXml()

void QgsRasterTransparency::writeXml ( QDomDocument &  doc,
QDomElement &  parentElem 
) const

Writes the transparency information to an XML document.

Definition at line 127 of file qgsrastertransparency.cpp.


The documentation for this class was generated from the following files: