22 #include <QDomDocument>
23 #include <QDomElement>
30 , mClassificationMin( std::numeric_limits<double>::quiet_NaN() )
31 , mClassificationMax( std::numeric_limits<double>::quiet_NaN() )
52 if ( origColorRampShader )
84 int band = elem.attribute(
"band",
"-1" ).toInt();
86 QDomElement rasterShaderElem = elem.firstChildElement(
"rastershader" );
87 if ( !rasterShaderElem.isNull() )
90 shader->
readXML( rasterShaderElem );
116 if ( !inputBlock || inputBlock->
isEmpty() )
130 if ( !alphaBlock || alphaBlock->
isEmpty() )
139 alphaBlock = inputBlock;
151 for (
size_t i = 0; i < ( size_t )width*height; i++ )
155 outputBlock->
setColor( i, myDefaultColor );
158 double val = inputBlock->
value( i );
159 int red, green, blue, alpha;
160 if ( !
mShader->
shade( val, &red, &green, &blue, &alpha ) )
162 outputBlock->
setColor( i, myDefaultColor );
169 red *= ( alpha / 255.0 );
170 blue *= ( alpha / 255.0 );
171 green *= ( alpha / 255.0 );
174 if ( !hasTransparency )
176 outputBlock->
setColor( i, qRgba( red, green, blue, alpha ) );
188 currentOpacity *= alphaBlock->
value( i ) / 255.0;
191 outputBlock->
setColor( i, qRgba( currentOpacity * red, currentOpacity * green, currentOpacity * blue, currentOpacity * alpha ) );
206 if ( parentElem.isNull() )
211 QDomElement rasterRendererElem = doc.createElement(
"rasterrenderer" );
213 rasterRendererElem.setAttribute(
"band",
mBand );
218 rasterRendererElem.setAttribute(
"classificationMin", QString::number(
mClassificationMin ) );
219 rasterRendererElem.setAttribute(
"classificationMax", QString::number(
mClassificationMax ) );
222 parentElem.appendChild( rasterRendererElem );
230 if ( shaderFunction )