21 #include <QDomDocument>
22 #include <QDomElement>
26 QgsRasterRenderer( input,
"singlebandgray" ), mGrayBand( grayBand ), mGradient( BlackToWhite ), mContrastEnhancement( 0 )
56 int grayBand = elem.attribute(
"grayBand",
"-1" ).toInt();
60 if ( elem.attribute(
"gradient" ) ==
"WhiteToBlack" )
65 QDomElement contrastEnhancementElem = elem.firstChildElement(
"contrastEnhancement" );
66 if ( !contrastEnhancementElem.isNull() )
70 ce->
readXML( contrastEnhancementElem );
85 QgsDebugMsg( QString(
"width = %1 height = %2" ).arg( width ).arg( height ) );
94 if ( !inputBlock || inputBlock->
isEmpty() )
106 if ( !alphaBlock || alphaBlock->
isEmpty() )
116 alphaBlock = inputBlock;
131 outputBlock->
setColor( i, myDefaultColor );
134 double grayVal = inputBlock->
value( i );
143 currentAlpha *= alphaBlock->
value( i ) / 255.0;
150 outputBlock->
setColor( i, myDefaultColor );
158 grayVal = 255 - grayVal;
163 outputBlock->
setColor( i, qRgba( grayVal, grayVal, grayVal, 255 ) );
167 outputBlock->
setColor( i, qRgba( currentAlpha * grayVal, currentAlpha * grayVal, currentAlpha * grayVal, currentAlpha * 255 ) );
182 if ( parentElem.isNull() )
187 QDomElement rasterRendererElem = doc.createElement(
"rasterrenderer" );
190 rasterRendererElem.setAttribute(
"grayBand",
mGrayBand );
195 gradient =
"BlackToWhite";
199 gradient =
"WhiteToBlack";
201 rasterRendererElem.setAttribute(
"gradient", gradient );
205 QDomElement contrastElem = doc.createElement(
"contrastEnhancement" );
207 rasterRendererElem.appendChild( contrastElem );
209 parentElem.appendChild( rasterRendererElem );