123 return mInput->block( bandNo,
extent, width, height, feedback );
125 const int bandNumber = 1;
127 QgsDebugMsgLevel( QStringLiteral(
"width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg(
extent.toString() ), 4 );
128 auto outputBlock = std::make_unique<QgsRasterBlock>();
130 return outputBlock.release();
132 double oversampling = 1.0;
134 double providerXRes = 0;
140 outputXRes =
extent.width() / width;
142 const double pixelRatio = outputXRes / providerXRes;
144 QgsDebugMsgLevel( QStringLiteral(
"xRes = %1 providerXRes = %2 pixelRatio = %3 oversampling = %4" ).arg( outputXRes ).arg( providerXRes ).arg( pixelRatio ).arg( oversampling ), 4 );
155 QgsDebugMsgLevel( QStringLiteral(
"oversampling %1" ).arg( oversampling ), 4 );
163 return mInput->block( bandNumber,
extent, width, height, feedback );
167 const double oversamplingX = (
static_cast< double >( width ) * oversampling ) / width;
168 const double oversamplingY = (
static_cast< double >( height ) * oversampling ) / height;
171 int tileBufferPixels = 0;
172 if ( providerXRes != 0 )
176 tileBufferPixels =
static_cast< int >( std::ceil(
mZoomedInResampler->tileBufferPixels() * oversampling ) );
180 tileBufferPixels =
static_cast< int >( std::ceil(
mZoomedOutResampler->tileBufferPixels() * oversampling ) );
183 const double sourceTileBufferSize = providerXRes * tileBufferPixels;
186 extent.yMinimum() - sourceTileBufferSize,
187 extent.xMaximum() + sourceTileBufferSize,
188 extent.yMaximum() + sourceTileBufferSize
191 const int resWidth =
static_cast< int >( std::round( width * oversamplingX ) ) + 2 * tileBufferPixels;
192 const int resHeight =
static_cast< int >( std::round( height * oversamplingY ) ) + 2 * tileBufferPixels;
194 std::unique_ptr< QgsRasterBlock > inputBlock(
mInput->block( bandNumber, bufferedExtent, resWidth, resHeight, feedback ) );
195 if ( !inputBlock || inputBlock->isEmpty() )
198 return outputBlock.release();
203 return outputBlock.release();
207 const QImage img = inputBlock->image();
209 const int resampleWidth =
static_cast< int >( std::round( width * ( bufferedExtent.
width() /
extent.width() ) ) );
210 const int resampleHeight =
static_cast< int >( std::round( height * ( bufferedExtent.
height() /
extent.height() ) ) );
219 dstImg = resamplerV2->resampleV2( img, QSize( resampleWidth, resampleHeight ) );
225 QImage dstImg = QImage( resampleWidth, resampleHeight, QImage::Format_ARGB32_Premultiplied );
236 dstImg = resamplerV2->resampleV2( img, QSize( resampleWidth, resampleHeight ) );
242 QImage dstImg = QImage( resampleWidth, resampleHeight, QImage::Format_ARGB32_Premultiplied );
251 dstImg = img.scaled( width, height );
255 const QImage cropped = tileBufferPixels > 0 ? dstImg.copy( ( resampleWidth - width ) / 2, ( resampleHeight - height ) / 2, width, height )
257 outputBlock->setImage( &cropped );
259 return outputBlock.release();
285 if ( filterElem.isNull() )
290 mMaxOversampling = filterElem.attribute( QStringLiteral(
"maxOversampling" ), QStringLiteral(
"2.0" ) ).toDouble();
292 const QString zoomedInResamplerType = filterElem.attribute( QStringLiteral(
"zoomedInResampler" ) );
293 if ( zoomedInResamplerType == QLatin1String(
"bilinear" ) )
297 else if ( zoomedInResamplerType == QLatin1String(
"cubic" ) )
302 const QString zoomedOutResamplerType = filterElem.attribute( QStringLiteral(
"zoomedOutResampler" ) );
303 if ( zoomedOutResamplerType == QLatin1String(
"bilinear" ) )
307 else if ( zoomedOutResamplerType == QLatin1String(
"cubic" ) )