Skip to content

Commit

Permalink
Use svg cache for svg fill layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jul 5, 2011
1 parent 2fcf608 commit 9d3c904
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/core/symbology-ng/qgsfillsymbollayerv2.cpp
Expand Up @@ -4,6 +4,7 @@

#include "qgsrendercontext.h"
#include "qgsproject.h"
#include "qgssvgcache.h"

#include <QPainter>
#include <QFile>
Expand Down Expand Up @@ -201,6 +202,18 @@ void QgsSVGFillSymbolLayer::startRender( QgsSymbolV2RenderContext& context )
return;
}

QColor fillColor( Qt::black );
QColor outlineColor( Qt::black );
double outlineWidth = 1;
int size = context.outputPixelSize( mPatternWidth );
const QImage& patternImage = QgsSvgCache::instance()->svgAsImage( mSvgFilePath, size, fillColor, outlineColor, outlineWidth,
context.renderContext().scaleFactor(), context.renderContext().rasterScaleFactor() );
QTransform brushTransform;
brushTransform.scale( 1.0 / context.renderContext().rasterScaleFactor(), 1.0 / context.renderContext().rasterScaleFactor() );
mBrush.setTextureImage( patternImage );
mBrush.setTransform( brushTransform );

#if 0
//create QImage with appropriate dimensions
int pixelWidth = context.outputPixelSize( mPatternWidth );
int pixelHeight = pixelWidth / mSvgViewBox.width() * mSvgViewBox.height();
Expand All @@ -227,6 +240,7 @@ void QgsSVGFillSymbolLayer::startRender( QgsSymbolV2RenderContext& context )
brushTransform.scale( 1.0 / context.renderContext().rasterScaleFactor(), 1.0 / context.renderContext().rasterScaleFactor() );
mBrush.setTextureImage( textureImage );
mBrush.setTransform( brushTransform );
#endif //0

if ( mOutline )
{
Expand Down

0 comments on commit 9d3c904

Please sign in to comment.