diff --git a/Modules/IO/IOGDAL/src/otbGDALOverviewsBuilder.cxx b/Modules/IO/IOGDAL/src/otbGDALOverviewsBuilder.cxx index ecfdfcbeb1690a06cc0a0a513a53a83c2b7923bd..5e15ca437386840f76b958dc5242ba9a4f2d3dcf 100644 --- a/Modules/IO/IOGDAL/src/otbGDALOverviewsBuilder.cxx +++ b/Modules/IO/IOGDAL/src/otbGDALOverviewsBuilder.cxx @@ -200,7 +200,7 @@ GDALOverviewsBuilder unsigned int n = std::min( count, - CountResolutions( factor ) + CountResolutions( factor , 1) ); for( unsigned int i=0; i<n; ++i ) diff --git a/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx b/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx index 15b403ce5bb789fae83311ce6c8791db7ff5a03e..76614c96afe42b8193043a8d8cd58f450f061bdc 100644 --- a/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx +++ b/Modules/Visualization/MonteverdiGui/src/mvdImportImagesDialog.cxx @@ -222,14 +222,22 @@ ImportImagesDialog I18nCoreApplication::SETTINGS_KEY_OVERVIEWS_SIZE ) ); - - count = - builder->CountResolutions( - 2, - value.isValid() - ? value.toInt() - : OVERVIEWS_SIZE_DEFAULT - ); + unsigned int threshold = + value.isValid() ? value.toInt() : OVERVIEWS_SIZE_DEFAULT; + + otb::GDALOverviewsBuilder::SizeVector ovrSizes; + builder->SetResolutionFactor(2); + // Count all resolution with minimum size 1 (the high requested count is + // clamped by the builder) + builder->ListResolutions(ovrSizes, 2, 9999); + // Count the number of levels with a least 1 size larger than the default size + for (unsigned int k=0 ; k<ovrSizes.size() ; k++) + { + if (std::max(ovrSizes[k][0],ovrSizes[k][1]) >= threshold) + count++; + else + break; + } } if( builder->GetOverviewsCount()>0 ) @@ -247,7 +255,6 @@ ImportImagesDialog builder->SetBypassEnabled(true); } - builder->SetResolutionFactor( 2 ); builder->SetNbResolutions( count ); builder->SetResamplingMethod( otb::GDAL_RESAMPLING_AVERAGE ); builder->SetCompressionMethod( otb::GDAL_COMPRESSION_NONE );