30 #include <QDomDocument>
31 #include <QDomElement>
37 , mZoomedInResampler( 0 )
38 , mZoomedOutResampler( 0 )
39 , mMaxOversampling( 2.0 )
137 if ( !
mInput )
return outputBlock;
139 double oversampling = 1.0;
146 double xRes = extent.
width() / width;
148 double pixelRatio = xRes / providerXRes;
150 QgsDebugMsg(
QString(
"xRes = %1 providerXRes = %2 pixelRatio = %3 oversampling = %4" ).arg( xRes ).arg( providerXRes ).arg( pixelRatio ).arg( oversampling ) );
172 return mInput->
block( bandNumber, extent, width, height );
176 double oversamplingX = (( double )width * oversampling ) / width;
177 double oversamplingY = (( double )height * oversampling ) / height;
181 int resWidth = width * oversamplingX;
182 int resHeight = height * oversamplingY;
185 if ( !inputBlock || inputBlock->
isEmpty() )
201 QImage dstImg =
QImage( width, height, QImage::Format_ARGB32_Premultiplied );
217 dstImg = img.
scaled( width, height );
228 if ( parentElem.
isNull() )
249 if ( filterElem.
isNull() )
256 QString zoomedInResamplerType = filterElem.
attribute(
"zoomedInResampler" );
257 if ( zoomedInResamplerType ==
"bilinear" )
261 else if ( zoomedInResamplerType ==
"cubic" )
266 QString zoomedOutResamplerType = filterElem.
attribute(
"zoomedOutResampler" );
267 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.
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const
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.
double toDouble(bool *ok) const
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).
QString number(int n, int base)
virtual QString type() const =0
bool setImage(const QImage *image)
set image.
void setAttribute(const QString &name, const QString &value)
~QgsRasterResampleFilter()
DataType
Raster data types.
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.
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.
Unknown or unspecified type.
Bilinear Raster Resampler.
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.
QDomElement createElement(const QString &tagName)
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.
double width() const
Width of the rectangle.
QgsRasterInterface * mInput
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
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.