** Fixed transparency in SVG sumbols

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@1925 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
larsl 2004-08-22 12:23:48 +00:00
parent e2396ff3af
commit d8d9ace386
3 changed files with 22 additions and 27 deletions

View File

@ -1,8 +1,11 @@
QGIS Change Log
ChangeLog,v 1.172 2004/08/21 15:30:18 larsl Exp
ChangeLog,v 1.173 2004/08/22 12:23:47 larsl Exp
------------------------------------------------------------------------------
Version 0.4 'Baby' .... development version
2004-08-22 [larsl] 0.4.0devel17
** Fixed transparency in SVG sumbols
2004-08-21 [larsl] 0.4.0devel16
** Added a black frame around the white rectangle around SVG symbols to make it look cleaner, can be removed when transparency is fixed

View File

@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
dnl configure.in,v 1.174 2004/08/21 15:30:18 larsl Exp
dnl configure.in,v 1.175 2004/08/22 12:23:47 larsl Exp
@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
MAJOR_VERSION=0
MINOR_VERSION=4
MICRO_VERSION=0
EXTRA_VERSION=16
EXTRA_VERSION=17
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
else

View File

@ -64,31 +64,23 @@ QPixmap QgsSVGCache::getPixmap(QString filename, double scaleFactor) {
}
// render and rescale it (with smoothing)
QPixmap pixmap;
if (oversampling != 1) {
QPixmap osPixmap(oversampling*width,oversampling*height);
osPixmap.fill(QColor(qRgba(255, 255, 255, 0)));
QPainter p(&osPixmap);
p.scale(scaleFactor*oversampling,scaleFactor*oversampling);
p.drawPicture(0,0,pic);
QImage osImage = osPixmap.convertToImage();
QImage image = osImage.smoothScale(width, height);
pixmap = QPixmap(image);
QPixmap osPixmap(oversampling*width,oversampling*height);
osPixmap.fill(QColor(qRgb(255, 255, 0))); QPainter p(&osPixmap);
p.scale(scaleFactor*oversampling,scaleFactor*oversampling);
p.drawPicture(0,0,pic);
QImage osImage = osPixmap.convertToImage();
// set a mask - this is probably terribly inefficient
osImage.setAlphaBuffer(true);
for (int i = 0; i < osImage.width(); ++i) {
for (int j = 0; j < osImage.height(); ++j) {
if (osImage.pixel(i, j) == qRgb(255, 255, 0)) {
osImage.setPixel(i, j, qRgba(255, 255, 0, 0));
}
}
}
else {
pixmap = QPixmap(width, height);
pixmap.fill(QColor(qRgba(255, 255, 255, 0)));
QPainter p(&pixmap);
p.scale(scaleFactor, scaleFactor);
p.drawPicture(0, 0, pic);
}
// FIXME - this frame is added because there already is an ugly white
// rectangle around the SVG symbol. The frame makes it look at least almost
// intentional. Can be removed when transparency is fixed.
QPainter p2(&pixmap);
p2.setPen(QColor(0, 0, 0));
p2.drawRect(0, 0, width, height);
if (scaleFactor != 1)
osImage = osImage.smoothScale(width, height);
QPixmap pixmap = QPixmap(osImage);
// cache it if possible, and remove other pixmaps from the cache
// if it grows too large