Class: QgsRasterTransparency¶
Defines the list of pixel values to be considered as transparent or semi transparent when rendering rasters.
Methods
Returns the transparency value for a single value pixel.  | 
|
Resets the transparency list to a single value.  | 
|
True if there are no entries in the pixel lists except the nodata value  | 
|
Returns the opacity (as a value from 0 to 1) for a set of RGB pixel values.  | 
|
Returns the opacity (as a value from 0 to 1) for a single value pixel.  | 
|
Reads the transparency information from an XML document.  | 
|
Sets the transparent single value pixel list, replacing the whole existing list.  | 
|
Sets the transparent three value pixel list, replacing the whole existing list.  | 
|
Returns the transparent single value pixel list.  | 
|
Returns the transparent three value pixel list.  | 
|
Writes the transparency information to an XML document.  | 
- class qgis.core.QgsRasterTransparency[source]¶
 Bases:
object- class TransparentSingleValuePixel¶
 Bases:
objectDefines the transparency for a range of single-band pixel values.
- includeMaximum¶
 Trueif pixels matching the max value should be considered transparent, orFalseif only pixels less than the max value should be transparent.Added in version 3.38.
- includeMinimum¶
 Trueif pixels matching the min value should be considered transparent, orFalseif only pixels greater than the min value should be transparent.Added in version 3.38.
- max¶
 Maximum pixel value to include in range.
- min¶
 Minimum pixel value to include in range.
- opacity¶
 Opacity for pixel, between 0 and 1.0.
Added in version 3.38.
- property percentTransparent¶
 
- class TransparentThreeValuePixel¶
 Bases:
objectDefines the transparency for a RGB pixel value.
- blue¶
 Blue pixel value.
- fuzzyToleranceBlue¶
 Fuzzy tolerance for blue values.
If non zero, the pixel’s blue component can deviate from values specified in this object by a maximum of this tolerance amount.
Added in version 3.40.
- fuzzyToleranceGreen¶
 Fuzzy tolerance for green values.
If non zero, the pixel’s green component can deviate from values specified in this object by a maximum of this tolerance amount.
Added in version 3.40.
- fuzzyToleranceRed¶
 Fuzzy tolerance for red values.
If non zero, the pixel’s red component can deviate from values specified in this object by a maximum of this tolerance amount.
Added in version 3.40.
- green¶
 Green pixel value.
- opacity¶
 Opacity for pixel, between 0 and 1.0.
Added in version 3.38.
- property percentTransparent¶
 
- red¶
 Red pixel value.
- alphaValue(self, value: float, globalTransparency: int = 255) int[source]¶
 Returns the transparency value for a single
valuepixel.Searches through the transparency list, and if a match is found, the global transparency value is scaled by the stored transparency value.
- Parameters:
 value (float) – the needle to search for in the transparency hay stack
globalTransparency (int = 255) – the overall transparency level for the layer
Deprecated since version 3.40: Use
opacityForValue()instead.- Return type:
 int
- alphaValue(self, redValue: float, greenValue: float, blueValue: float, globalTransparency: int = 255) int[source]
 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:
 redValue (float) – the red portion of the needle to search for in the transparency hay stack
greenValue (float) – the green portion of the needle to search for in the transparency hay stack
blueValue (float) – the green portion of the needle to search for in the transparency hay stack
globalTransparency (int = 255) – the overall transparency level for the layer
Deprecated since version 3.40: Use
opacityForRgbValues()instead.- Return type:
 int
- initializeTransparentPixelList(self, value: float)[source]¶
 Resets the transparency list to a single
value.- Parameters:
 value (float)
- initializeTransparentPixelList(self, redValue: float, greenValue: float, blueValue: float)[source]
 Resets the transparency list to single red, green, and blue values.
- Parameters:
 redValue (float)
greenValue (float)
blueValue (float)
- isEmpty(self) bool[source]¶
 True if there are no entries in the pixel lists except the nodata value
- Return type:
 bool
- opacityForRgbValues(self, redValue: float, greenValue: float, blueValue: float) float[source]¶
 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.
Added in version 3.38.
- Parameters:
 redValue (float)
greenValue (float)
blueValue (float)
- Return type:
 float
- opacityForValue(self, value: float) float[source]¶
 Returns the opacity (as a value from 0 to 1) for a single
valuepixel.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.
Added in version 3.38.
- Parameters:
 value (float)
- Return type:
 float
- readXml(self, elem: QDomElement)[source]¶
 Reads the transparency information from an XML document.
- Parameters:
 elem (QDomElement)
- setTransparentSingleValuePixelList(self, newList: Iterable[QgsRasterTransparency.TransparentSingleValuePixel])[source]¶
 Sets the transparent single value pixel list, replacing the whole existing list.
See also
- Parameters:
 newList (Iterable[QgsRasterTransparency.TransparentSingleValuePixel])
- setTransparentThreeValuePixelList(self, newList: Iterable[QgsRasterTransparency.TransparentThreeValuePixel])[source]¶
 Sets the transparent three value pixel list, replacing the whole existing list.
See also
- Parameters:
 newList (Iterable[QgsRasterTransparency.TransparentThreeValuePixel])
- transparentSingleValuePixelList(self) List[QgsRasterTransparency.TransparentSingleValuePixel]¶
 Returns the transparent single value pixel list.
See also
- Return type:
 
- transparentThreeValuePixelList(self) List[QgsRasterTransparency.TransparentThreeValuePixel]¶
 Returns the transparent three value pixel list.
See also
- Return type: