22 #include <QDomDocument>
23 #include <QDomElement>
115 QgsDebugMsg( QString(
"width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.
toString() ) );
126 if ( !inputBlock || inputBlock->
isEmpty() )
147 QRgb myNoDataColor = qRgba( 0, 0, 0, 0 );
151 double f = qPow((
mContrast + 100 ) / 100.0, 2 );
153 for (
size_t i = 0; i < ( size_t )width*height; i++ )
155 if ( inputBlock->
color( i ) == myNoDataColor )
157 outputBlock->
setColor( i, myNoDataColor );
161 myColor = inputBlock->
color( i );
162 alpha = qAlpha( myColor );
168 outputBlock->
setColor( i, qRgba( r, g, b, alpha ) );
180 return qBound( 0, (
int )(((((( colorComponent / 255.0 ) - 0.5 ) * contrastFactor ) + 0.5 ) * 255 ) + brightness ), 255 );
186 double alphaFactor = alpha / 255.;
187 double adjustedColor = colorComponent / alphaFactor;
190 return alphaFactor * qBound( 0., (((((( adjustedColor / 255.0 ) - 0.5 ) * contrastFactor ) + 0.5 ) * 255 ) + brightness ), 255. );
196 if ( parentElem.isNull() )
201 QDomElement filterElem = doc.createElement(
"brightnesscontrast" );
203 filterElem.setAttribute(
"brightness", QString::number(
mBrightness ) );
204 filterElem.setAttribute(
"contrast", QString::number(
mContrast ) );
205 parentElem.appendChild( filterElem );
210 if ( filterElem.isNull() )
215 mBrightness = filterElem.attribute(
"brightness",
"0" ).toInt();
216 mContrast = filterElem.attribute(
"contrast",
"0" ).toInt();