QgsRasterRenderer* QgsSingleBandGrayRenderer::create( const QDomElement& elem, QgsRasterInterface* input ) { if ( elem.isNull() ) { return 0; } int grayBand = elem.attribute( "grayBand", "-1" ).toInt(); QgsSingleBandGrayRenderer* r = new QgsSingleBandGrayRenderer( input, grayBand ); r->readXML( elem ); if ( elem.attribute( "gradient" ) == "WhiteToBlack" ) { r->setGradient( WhiteToBlack ); // BlackToWhite is default } QDomElement contrastEnhancementElem = elem.firstChildElement( "contrastEnhancement" ); if ( !contrastEnhancementElem.isNull() ) { QgsContrastEnhancement* ce = new QgsContrastEnhancement(( QGis::DataType )( input->dataType( grayBand ) ) ); ce->readXML( contrastEnhancementElem ); r->setContrastEnhancement( ce ); } return r; }
QgsRasterRenderer* QgsMultiBandColorRenderer::create( const QDomElement& elem, QgsRasterInterface* input ) { if ( elem.isNull() ) { return 0; } //red band, green band, blue band int redBand = elem.attribute( "redBand", "-1" ).toInt(); int greenBand = elem.attribute( "greenBand", "-1" ).toInt(); int blueBand = elem.attribute( "blueBand", "-1" ).toInt(); //contrast enhancements QgsContrastEnhancement* redContrastEnhancement = 0; QDomElement redContrastElem = elem.firstChildElement( "redContrastEnhancement" ); if ( !redContrastElem.isNull() ) { redContrastEnhancement = new QgsContrastEnhancement(( QgsContrastEnhancement::QgsRasterDataType )( input->dataType( redBand ) ) ); redContrastEnhancement->readXML( redContrastElem ); } QgsContrastEnhancement* greenContrastEnhancement = 0; QDomElement greenContrastElem = elem.firstChildElement( "greenContrastEnhancement" ); if ( !greenContrastElem.isNull() ) { greenContrastEnhancement = new QgsContrastEnhancement(( QgsContrastEnhancement::QgsRasterDataType )( input->dataType( greenBand ) ) ); greenContrastEnhancement->readXML( greenContrastElem ); } QgsContrastEnhancement* blueContrastEnhancement = 0; QDomElement blueContrastElem = elem.firstChildElement( "blueContrastEnhancement" ); if ( !blueContrastElem.isNull() ) { blueContrastEnhancement = new QgsContrastEnhancement(( QgsContrastEnhancement::QgsRasterDataType )( input->dataType( blueBand ) ) ); blueContrastEnhancement->readXML( blueContrastElem ); } QgsRasterRenderer* r = new QgsMultiBandColorRenderer( input, redBand, greenBand, blueBand, redContrastEnhancement, greenContrastEnhancement, blueContrastEnhancement ); r->readXML( elem ); return r; }