127 return mInput->block( bandNo,
extent, width, height, feedback );
129 const int bandNumber = 1;
131 QgsDebugMsgLevel( u
"width = %1 height = %2 extent = %3"_s.arg( width ).arg( height ).arg(
extent.toString() ), 4 );
132 auto outputBlock = std::make_unique<QgsRasterBlock>();
134 return outputBlock.release();
136 double oversampling = 1.0;
138 double providerXRes = 0;
144 outputXRes =
extent.width() / width;
146 const double pixelRatio = outputXRes / providerXRes;
148 QgsDebugMsgLevel( u
"xRes = %1 providerXRes = %2 pixelRatio = %3 oversampling = %4"_s.arg( outputXRes ).arg( providerXRes ).arg( pixelRatio ).arg( oversampling ), 4 );
167 return mInput->block( bandNumber,
extent, width, height, feedback );
171 const double oversamplingX = (
static_cast< double >( width ) * oversampling ) / width;
172 const double oversamplingY = (
static_cast< double >( height ) * oversampling ) / height;
175 int tileBufferPixels = 0;
176 if ( providerXRes != 0 )
180 tileBufferPixels =
static_cast< int >( std::ceil(
mZoomedInResampler->tileBufferPixels() * oversampling ) );
184 tileBufferPixels =
static_cast< int >( std::ceil(
mZoomedOutResampler->tileBufferPixels() * oversampling ) );
187 const double sourceTileBufferSize = providerXRes * tileBufferPixels;
190 extent.yMinimum() - sourceTileBufferSize,
191 extent.xMaximum() + sourceTileBufferSize,
192 extent.yMaximum() + sourceTileBufferSize
195 const int resWidth =
static_cast< int >( std::round( width * oversamplingX ) ) + 2 * tileBufferPixels;
196 const int resHeight =
static_cast< int >( std::round( height * oversamplingY ) ) + 2 * tileBufferPixels;
198 std::unique_ptr< QgsRasterBlock > inputBlock(
mInput->block( bandNumber, bufferedExtent, resWidth, resHeight, feedback ) );
199 if ( !inputBlock || inputBlock->isEmpty() )
202 return outputBlock.release();
207 return outputBlock.release();
211 const QImage img = inputBlock->image();
213 const int resampleWidth =
static_cast< int >( std::round( width * ( bufferedExtent.
width() /
extent.width() ) ) );
214 const int resampleHeight =
static_cast< int >( std::round( height * ( bufferedExtent.
height() /
extent.height() ) ) );
223 dstImg = resamplerV2->resampleV2( img, QSize( resampleWidth, resampleHeight ) );
229 QImage dstImg = QImage( resampleWidth, resampleHeight, QImage::Format_ARGB32_Premultiplied );
240 dstImg = resamplerV2->resampleV2( img, QSize( resampleWidth, resampleHeight ) );
246 QImage dstImg = QImage( resampleWidth, resampleHeight, QImage::Format_ARGB32_Premultiplied );
255 dstImg = img.scaled( width, height );
259 const QImage cropped = tileBufferPixels > 0 ? dstImg.copy( ( resampleWidth - width ) / 2, ( resampleHeight - height ) / 2, width, height )
261 outputBlock->setImage( &cropped );
263 return outputBlock.release();
289 if ( filterElem.isNull() )
294 mMaxOversampling = filterElem.attribute( u
"maxOversampling"_s, u
"2.0"_s ).toDouble();
296 const QString zoomedInResamplerType = filterElem.attribute( u
"zoomedInResampler"_s );
297 if ( zoomedInResamplerType ==
"bilinear"_L1 )
301 else if ( zoomedInResamplerType ==
"cubic"_L1 )
306 const QString zoomedOutResamplerType = filterElem.attribute( u
"zoomedOutResampler"_s );
307 if ( zoomedOutResamplerType ==
"bilinear"_L1 )
311 else if ( zoomedOutResamplerType ==
"cubic"_L1 )