Skip to content
Permalink
Browse files

Added option to generate thumbnail using qimage rather than qpixmap

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14372 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Oct 13, 2010
1 parent 62cdb41 commit b2d186289fbca29de5aa27d3683ba1bbf880599f
Showing with 37 additions and 0 deletions.
  1. +33 −0 src/core/raster/qgsrasterlayer.cpp
  2. +4 −0 src/core/raster/qgsrasterlayer.h
@@ -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();
@@ -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();

0 comments on commit b2d1862

Please sign in to comment.
You can’t perform that action at this time.