Skip to content

Commit

Permalink
Add asImage method for QgsSymbol
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Sep 19, 2014
1 parent 11be64d commit 8c327ed
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/core/symbology-ng/qgssymbolv2.sip
Expand Up @@ -85,6 +85,8 @@ class QgsSymbolV2
//! @note customContext parameter added in 2.6
void drawPreviewIcon( QPainter* painter, QSize size, QgsRenderContext* customContext = 0 );

QImage asImage( QSize size, QgsRenderContext* customContext = 0 );

QImage bigSymbolPreviewImage();

QString dump() const;
Expand Down
13 changes: 13 additions & 0 deletions src/core/symbology-ng/qgssymbolv2.cpp
Expand Up @@ -308,6 +308,19 @@ void QgsSymbolV2::drawPreviewIcon( QPainter* painter, QSize size, QgsRenderConte
}
}

QImage QgsSymbolV2::asImage( QSize size, QgsRenderContext* customContext )
{
QImage image( size , QImage::Format_ARGB32_Premultiplied );
image.fill( 0 );

QPainter p( &image );
p.setRenderHint( QPainter::Antialiasing );

drawPreviewIcon( &p, size, customContext );

return image;
}


QImage QgsSymbolV2::bigSymbolPreviewImage()
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/symbology-ng/qgssymbolv2.h
Expand Up @@ -110,6 +110,8 @@ class CORE_EXPORT QgsSymbolV2
//! @note customContext parameter added in 2.6
void drawPreviewIcon( QPainter* painter, QSize size, QgsRenderContext* customContext = 0 );

QImage asImage( QSize size, QgsRenderContext* customContext = 0 );

QImage bigSymbolPreviewImage();

QString dump() const;
Expand Down

0 comments on commit 8c327ed

Please sign in to comment.