21 #include <QDomDocument> 22 #include <QDomElement> 27 QgsRasterRenderer( input, QStringLiteral(
"singlebandcolordata" ) ), mBand( band )
46 int band = elem.attribute( QStringLiteral(
"band" ), QStringLiteral(
"-1" ) ).toInt();
56 std::unique_ptr< QgsRasterBlock > outputBlock(
new QgsRasterBlock() );
59 return outputBlock.release();
62 std::unique_ptr< QgsRasterBlock > inputBlock(
mInput->
block( mBand, extent, width, height, feedback ) );
63 if ( !inputBlock || inputBlock->isEmpty() )
66 return outputBlock.release();
70 if ( !hasTransparency )
74 return inputBlock.release();
79 return outputBlock.release();
85 QRgb *inputBits = ( QRgb * )inputBlock->bits();
86 QRgb *outputBits = ( QRgb * )outputBlock->bits();
89 QRgb
c = inputBits[i];
93 return outputBlock.release();
98 if ( parentElem.isNull() )
101 QDomElement rasterRendererElem = doc.createElement( QStringLiteral(
"rasterrenderer" ) );
103 rasterRendererElem.setAttribute( QStringLiteral(
"band" ), mBand );
104 parentElem.appendChild( rasterRendererElem );
120 if ( !input )
return false;
A rectangle specified with double values.
bool setInput(QgsRasterInterface *input) override
Set input.
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
QgsSingleBandColorDataRenderer * clone() const override
Clone itself, create deep copy.
virtual QgsRasterInterface * input() const
Current input.
void writeXml(QDomDocument &doc, QDomElement &parentElem) const override
Write base class members to xml.
QgsSingleBandColorDataRenderer(QgsRasterInterface *input, int band)
virtual Qgis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
Raster renderer pipe for single band color.
bool usesTransparency() const
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
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 copyCommonProperties(const QgsRasterRenderer *other, bool copyMinMaxOrigin=true)
Copies common properties like opacity / transparency data from other renderer.
void readXml(const QDomElement &rendererElem) override
Sets base class members from xml. Usually called from create() methods of subclasses.
Base class for processing filters like renderers, reprojector, resampler etc.
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
QList< int > usesBands() const override
Returns a list of band numbers used by the renderer.
static QgsRasterRenderer * create(const QDomElement &elem, QgsRasterInterface *input)
virtual QgsRectangle extent() const
Gets the extent of the interface.
double mOpacity
Global alpha value (0-1)
QgsRasterInterface * mInput
void _writeXml(QDomDocument &doc, QDomElement &rasterRendererElem) const
Write upper class info into rasterrenderer element (called by writeXml method of subclasses) ...
Feedback object tailored for raster block reading.
Raster renderer pipe that applies colors to a raster.
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.