mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-03 00:04:47 -04:00
assign correct raster type to the paletted raster with alpha band (fix #61283)
This commit is contained in:
parent
127ff85935
commit
4b5129f940
@ -809,18 +809,29 @@ void QgsRasterLayer::setDataProvider( QString const &provider, const QgsDataProv
|
||||
}
|
||||
else if ( bandCount == 2 )
|
||||
{
|
||||
// handle singleband gray with alpha
|
||||
// handle singleband gray and paletted with alpha
|
||||
auto colorInterpretationIsGrayOrUndefined = []( Qgis::RasterColorInterpretation interpretation )
|
||||
{
|
||||
return interpretation == Qgis::RasterColorInterpretation::GrayIndex
|
||||
|| interpretation == Qgis::RasterColorInterpretation::Undefined;
|
||||
};
|
||||
|
||||
auto colorInterpretationIsPaletted = []( Qgis::RasterColorInterpretation interpretation )
|
||||
{
|
||||
return interpretation == Qgis::RasterColorInterpretation::PaletteIndex
|
||||
|| interpretation == Qgis::RasterColorInterpretation::ContinuousPalette;
|
||||
};
|
||||
|
||||
if ( ( colorInterpretationIsGrayOrUndefined( mDataProvider->colorInterpretation( 1 ) ) && mDataProvider->colorInterpretation( 2 ) == Qgis::RasterColorInterpretation::AlphaBand )
|
||||
|| ( mDataProvider->colorInterpretation( 1 ) == Qgis::RasterColorInterpretation::AlphaBand && colorInterpretationIsGrayOrUndefined( mDataProvider->colorInterpretation( 2 ) ) ) )
|
||||
{
|
||||
mRasterType = Qgis::RasterLayerType::GrayOrUndefined;
|
||||
}
|
||||
else if ( ( colorInterpretationIsPaletted( mDataProvider->colorInterpretation( 1 ) ) && mDataProvider->colorInterpretation( 2 ) == Qgis::RasterColorInterpretation::AlphaBand )
|
||||
|| ( mDataProvider->colorInterpretation( 1 ) == Qgis::RasterColorInterpretation::AlphaBand && colorInterpretationIsPaletted( mDataProvider->colorInterpretation( 2 ) ) ) )
|
||||
{
|
||||
mRasterType = Qgis::RasterLayerType::Palette;
|
||||
}
|
||||
else
|
||||
{
|
||||
mRasterType = Qgis::RasterLayerType::MultiBand;
|
||||
|
Loading…
x
Reference in New Issue
Block a user