From 6001cdcfcab78346be93a3bb7b478c67a130691e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 5 Nov 2011 18:21:32 +0000 Subject: [PATCH] 0000474: Wrong background of SVG pixmaps git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5094 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Gui/BitmapFactory.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 19a57fe904..21b6dead5b 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -281,9 +281,9 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize { #ifdef QTWEBKIT QWebView webView; - QPalette pal = webView.palette(); - pal.setColor(QPalette::Background, Qt::transparent); - webView.setPalette(pal); + QPalette pal = webView.palette(); + pal.setColor(QPalette::Background, Qt::transparent); + webView.setPalette(pal); webView.setContent(contents, QString::fromAscii("image/svg+xml")); QString node = QString::fromAscii("document.rootElement.nodeName"); QString root = webView.page()->mainFrame()->evaluateJavaScript(node).toString(); @@ -304,16 +304,17 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize QPainter p(&image); #ifdef QTWEBKIT - qreal xs = size.isValid() ? size.width() / ww : 1.0; - qreal ys = size.isValid() ? size.height() / hh : 1.0; - p.scale(xs, ys); - - // the best quality - p.setRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::TextAntialiasing); - p.setRenderHint(QPainter::SmoothPixmapTransform); - webView.page()->mainFrame()->render(&p); -#else + qreal xs = size.isValid() ? size.width() / ww : 1.0; + qreal ys = size.isValid() ? size.height() / hh : 1.0; + p.scale(xs, ys); + + // the best quality + p.setRenderHint(QPainter::Antialiasing); + p.setRenderHint(QPainter::TextAntialiasing); + p.setRenderHint(QPainter::SmoothPixmapTransform); + p.setOpacity(0); // important to keep transparent background + webView.page()->mainFrame()->render(&p); +#else // tmp. disable the report window to suppress some bothering warnings Base::Console().SetEnabledMsgType("ReportOutput", ConsoleMsgType::MsgType_Wrn, false); QSvgRenderer svg(contents);