Added option to generate thumbnail using qimage rather than qpixmap

git-svn-id: http://svn.osgeo.org/qgis/trunk@14372 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
timlinux 2010-10-13 19:37:34 +00:00
parent 2955327acf
commit 4ef44ddbd1
2 changed files with 37 additions and 0 deletions

View File

@ -3680,6 +3680,39 @@ void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap )
}
void QgsRasterLayer::thumbnailAsImage( QImage * thepImage )
{
//TODO: This should be depreciated and a new function written that just returns a new QImage, it will be safer
if ( 0 == thepImage ) { return; }
thepImage->fill(Qt::white); //defaults to white
// Raster providers are disabled (for the moment)
if ( mProviderKey.isEmpty() )
{
QgsRasterViewPort *myRasterViewPort = new QgsRasterViewPort();
myRasterViewPort->rectXOffset = 0;
myRasterViewPort->rectYOffset = 0;
myRasterViewPort->clippedXMin = 0;
myRasterViewPort->clippedXMax = mWidth;
myRasterViewPort->clippedYMin = mHeight;
myRasterViewPort->clippedYMax = 0;
myRasterViewPort->clippedWidth = mWidth;
myRasterViewPort->clippedHeight = mHeight;
myRasterViewPort->topLeftPoint = QgsPoint( 0, 0 );
myRasterViewPort->bottomRightPoint = QgsPoint( thepImage->width(), thepImage->height() );
myRasterViewPort->drawableAreaXDim = thepImage->width();
myRasterViewPort->drawableAreaYDim = thepImage->height();
QPainter * myQPainter = new QPainter( thepImage );
draw( myQPainter, myRasterViewPort );
delete myRasterViewPort;
myQPainter->end();
delete myQPainter;
}
}
void QgsRasterLayer::triggerRepaint()
{
emit repaintRequested();

View File

@ -619,6 +619,10 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
/** \brief Draws a thumbnail of the rasterlayer into the supplied pixmap pointer */
void thumbnailAsPixmap( QPixmap * theQPixmap );
/** \brief Draws a thumbnail of the rasterlayer into the supplied QImage pointer
* @note added in QGIS 1.6
* */
void thumbnailAsImage( QImage * thepImage );
/** \brief Emit a signal asking for a repaint. (inherited from maplayer) */
void triggerRepaint();