Skip to content

Commit 4ef44dd

Browse files
author
timlinux
committedOct 13, 2010
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
1 parent 2955327 commit 4ef44dd

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
 

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,6 +3680,39 @@ void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap )
36803680

36813681
}
36823682

3683+
void QgsRasterLayer::thumbnailAsImage( QImage * thepImage )
3684+
{
3685+
//TODO: This should be depreciated and a new function written that just returns a new QImage, it will be safer
3686+
if ( 0 == thepImage ) { return; }
3687+
3688+
thepImage->fill(Qt::white); //defaults to white
3689+
3690+
// Raster providers are disabled (for the moment)
3691+
if ( mProviderKey.isEmpty() )
3692+
{
3693+
QgsRasterViewPort *myRasterViewPort = new QgsRasterViewPort();
3694+
myRasterViewPort->rectXOffset = 0;
3695+
myRasterViewPort->rectYOffset = 0;
3696+
myRasterViewPort->clippedXMin = 0;
3697+
myRasterViewPort->clippedXMax = mWidth;
3698+
myRasterViewPort->clippedYMin = mHeight;
3699+
myRasterViewPort->clippedYMax = 0;
3700+
myRasterViewPort->clippedWidth = mWidth;
3701+
myRasterViewPort->clippedHeight = mHeight;
3702+
myRasterViewPort->topLeftPoint = QgsPoint( 0, 0 );
3703+
myRasterViewPort->bottomRightPoint = QgsPoint( thepImage->width(), thepImage->height() );
3704+
myRasterViewPort->drawableAreaXDim = thepImage->width();
3705+
myRasterViewPort->drawableAreaYDim = thepImage->height();
3706+
3707+
QPainter * myQPainter = new QPainter( thepImage );
3708+
draw( myQPainter, myRasterViewPort );
3709+
delete myRasterViewPort;
3710+
myQPainter->end();
3711+
delete myQPainter;
3712+
}
3713+
3714+
}
3715+
36833716
void QgsRasterLayer::triggerRepaint()
36843717
{
36853718
emit repaintRequested();

‎src/core/raster/qgsrasterlayer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,10 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
619619

620620
/** \brief Draws a thumbnail of the rasterlayer into the supplied pixmap pointer */
621621
void thumbnailAsPixmap( QPixmap * theQPixmap );
622+
/** \brief Draws a thumbnail of the rasterlayer into the supplied QImage pointer
623+
* @note added in QGIS 1.6
624+
* */
625+
void thumbnailAsImage( QImage * thepImage );
622626

623627
/** \brief Emit a signal asking for a repaint. (inherited from maplayer) */
624628
void triggerRepaint();

0 commit comments

Comments
 (0)
Please sign in to comment.