Skip to content

Commit

Permalink
Added option to generate thumbnail using qimage rather than qpixmap
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@14372 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Oct 13, 2010
1 parent 2955327 commit 4ef44dd
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -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();
Expand Down
4 changes: 4 additions & 0 deletions src/core/raster/qgsrasterlayer.h
Expand Up @@ -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();
Expand Down

0 comments on commit 4ef44dd

Please sign in to comment.