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 ) );
170 return mInput->
block( bandNumber, extent, width, height );
174 double oversamplingX = (( double )width * oversampling ) / width;
175 double oversamplingY = (( double )height * oversampling ) / height;
179 int resWidth = width * oversamplingX;
180 int resHeight = height * oversamplingY;
183 if ( !inputBlock || inputBlock->
isEmpty() )
197 QImage img = inputBlock->
image();
199 QImage dstImg = QImage( width, height, QImage::Format_ARGB32_Premultiplied );
215 dstImg = img.scaled( width, height );
226 if ( parentElem.isNull() )
231 QDomElement rasterRendererElem = doc.createElement(
"rasterresampler" );
233 rasterRendererElem.setAttribute(
"maxOversampling", QString::number(
mMaxOversampling ) );
242 parentElem.appendChild( rasterRendererElem );
247 if ( filterElem.isNull() )
252 mMaxOversampling = filterElem.attribute(
"maxOversampling",
"2.0" ).toDouble();
254 QString zoomedInResamplerType = filterElem.attribute(
"zoomedInResampler" );
255 if ( zoomedInResamplerType ==
"bilinear" )
259 else if ( zoomedInResamplerType ==
"cubic" )
264 QString zoomedOutResamplerType = filterElem.attribute(
"zoomedOutResampler" );
265 if ( zoomedOutResamplerType ==
"bilinear" )
virtual int bandCount() const =0
Get number of bands.
A rectangle specified with double values.
void setMaxOversampling(double os)
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)
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).
int bandCount() const
Get number of bands.
virtual QString type() const =0
bool setImage(const QImage *image)
set image.
virtual QgsRectangle extent()=0
Get the extent of the data source.
~QgsRasterResampleFilter()
QGis::DataType dataType(int bandNo) const
Returns data type for the band specified by number.
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.
bool setInput(QgsRasterInterface *input)
Set input.
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.
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.
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height)
Read block of data using given extent and size.
void writeXML(QDomDocument &doc, QDomElement &parentElem) const
Write base class members to xml.
QgsRasterInterface * clone() const
Clone itself, create deep copy.
double width() const
Width of the rectangle.
QgsRasterInterface * mInput
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
bool isEmpty() const
Returns true if block is empty, i.e.
Base class for raster data providers.