30 #include <QDomDocument> 31 #include <QDomElement> 37 mZoomedInResampler( 0 ), mZoomedOutResampler( 0 ),
38 mMaxOversampling( 2.0 )
134 QgsDebugMsg( QString(
"width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.
toString() ) );
136 if ( !
mInput )
return outputBlock;
138 double oversampling = 1.0;
145 double xRes = extent.
width() / width;
147 double pixelRatio = xRes / providerXRes;
149 QgsDebugMsg( QString(
"xRes = %1 providerXRes = %2 pixelRatio = %3 oversampling = %4" ).arg( xRes ).arg( providerXRes ).arg( pixelRatio ).arg( oversampling ) );
160 QgsDebugMsg( QString(
"oversampling %1" ).arg( oversampling ) );
171 return mInput->
block( bandNumber, extent, width, height );
175 double oversamplingX = (( double )width * oversampling ) / width;
176 double oversamplingY = (( double )height * oversampling ) / height;
180 int resWidth = width * oversamplingX;
181 int resHeight = height * oversamplingY;
184 if ( !inputBlock || inputBlock->
isEmpty() )
198 QImage img = inputBlock->
image();
200 QImage dstImg = QImage( width, height, QImage::Format_ARGB32_Premultiplied );
216 dstImg = img.scaled( width, height );
227 if ( parentElem.isNull() )
232 QDomElement rasterRendererElem = doc.createElement(
"rasterresampler" );
234 rasterRendererElem.setAttribute(
"maxOversampling", QString::number(
mMaxOversampling ) );
243 parentElem.appendChild( rasterRendererElem );
248 if ( filterElem.isNull() )
253 mMaxOversampling = filterElem.attribute(
"maxOversampling",
"2.0" ).toDouble();
255 QString zoomedInResamplerType = filterElem.attribute(
"zoomedInResampler" );
256 if ( zoomedInResamplerType ==
"bilinear" )
260 else if ( zoomedInResamplerType ==
"cubic" )
265 QString zoomedOutResamplerType = filterElem.attribute(
"zoomedOutResampler" );
266 if ( zoomedOutResamplerType ==
"bilinear" )
virtual int bandCount() const =0
Get number of bands.
A rectangle specified with double values.
void setMaxOversampling(double os)
QGis::DataType dataType(int bandNo) const override
Returns data type for the band specified by number.
Interface for resampling rasters (e.g.
virtual void resample(const QImage &srcImage, QImage &dstImage)=0
virtual const QgsRasterInterface * srcInput() const
Get source / raw input, the first in pipe, usually provider.
virtual QgsRasterInterface * input() const
Current input.
Resample filter pipe for rasters.
void readXML(const QDomElement &filterElem) override
Sets base class members from xml.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
QgsRasterResampler * mZoomedOutResampler
Resampler used if raster resolution is higher than raster resolution (zoomed out).
virtual QString type() const =0
bool setImage(const QImage *image)
set image.
~QgsRasterResampleFilter()
virtual QGis::DataType dataType(int bandNo) const =0
Returns data type for the band specified by number.
Base class for processing filters like renderers, reprojector, resampler etc.
double mMaxOversampling
Maximum boundary for oversampling (to avoid too much data traffic).
bool reset(QGis::DataType theDataType, int theWidth, int theHeight)
Reset block.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
bool setInput(QgsRasterInterface *input) override
Set input.
virtual QgsRectangle extent() override=0
Get the extent of the data source.
virtual QgsRectangle extent()
Get the extent of the interface.
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height) override
Read block of data using given extent and size.
QgsRasterInterface * clone() const override
Clone itself, create deep copy.
void setZoomedInResampler(QgsRasterResampler *r)
Set resampler for zoomed in scales.
virtual int xSize() const
Get raster size.
Bilinear Raster Resampler.
DataType
Raster data types.
virtual QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height)=0
Read block of data using given extent and size.
virtual QgsRasterResampler * clone() const =0
void setZoomedOutResampler(QgsRasterResampler *r)
Set resampler for zoomed out scales.
QgsRasterResampler * mZoomedInResampler
Resampler used if screen resolution is higher than raster resolution (zoomed in). ...
QgsRasterResampleFilter(QgsRasterInterface *input=0)
QImage image() const
Get image if type is color.
void writeXML(QDomDocument &doc, QDomElement &parentElem) const override
Write base class members to xml.
double width() const
Width of the rectangle.
QgsRasterInterface * mInput
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
int bandCount() const override
Get number of bands.
bool isEmpty() const
Returns true if block is empty, i.e.
Base class for raster data providers.