summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Crémoux <cremoux.david@sanalevim.net>2019-02-01 11:54:25 +0300
committerEirik Aavitsland <eirik.aavitsland@qt.io>2019-02-06 12:36:12 +0000
commita91a65632c4d830070e1ca9bbda7e355f1459414 (patch)
tree1f47b068f5691ae8c359d761613deef43030b3a1 /src
parent74f7566527c6ed3c47fac873e90942f2834d248f (diff)
downloadqtsvg-a91a65632c4d830070e1ca9bbda7e355f1459414.tar.gz
Fix QSvgRenderer incorrect render of svg:image
The bounds of QSvgImage are integer based (QRect) which cause rounding issues when decimals values are used to define image (image shifted and with incorrect size). Changing the bounds to QRectF solves the issue. Fixes: QTBUG-73445 Change-Id: I49828e2c0b1917ec878844d520aac182581c23fb Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/svg/qsvggraphics.cpp10
-rw-r--r--src/svg/qsvggraphics_p.h4
-rw-r--r--src/svg/qsvghandler.cpp8
3 files changed, 11 insertions, 11 deletions
diff --git a/src/svg/qsvggraphics.cpp b/src/svg/qsvggraphics.cpp
index 5b273af..12f2349 100644
--- a/src/svg/qsvggraphics.cpp
+++ b/src/svg/qsvggraphics.cpp
@@ -121,14 +121,14 @@ void QSvgArc::draw(QPainter *p, QSvgExtraStates &states)
}
QSvgImage::QSvgImage(QSvgNode *parent, const QImage &image,
- const QRect &bounds)
+ const QRectF &bounds)
: QSvgNode(parent), m_image(image),
m_bounds(bounds)
{
- if (m_bounds.width() == 0)
- m_bounds.setWidth(m_image.width());
- if (m_bounds.height() == 0)
- m_bounds.setHeight(m_image.height());
+ if (m_bounds.width() == 0.0)
+ m_bounds.setWidth(static_cast<qreal>(m_image.width()));
+ if (m_bounds.height() == 0.0)
+ m_bounds.setHeight(static_cast<qreal>(m_image.height()));
}
void QSvgImage::draw(QPainter *p, QSvgExtraStates &states)
diff --git a/src/svg/qsvggraphics_p.h b/src/svg/qsvggraphics_p.h
index 6e5b9d6..1138d1a 100644
--- a/src/svg/qsvggraphics_p.h
+++ b/src/svg/qsvggraphics_p.h
@@ -104,13 +104,13 @@ class Q_SVG_PRIVATE_EXPORT QSvgImage : public QSvgNode
{
public:
QSvgImage(QSvgNode *parent, const QImage &image,
- const QRect &bounds);
+ const QRectF &bounds);
void draw(QPainter *p, QSvgExtraStates &states) override;
Type type() const override;
QRectF bounds(QPainter *p, QSvgExtraStates &states) const override;
private:
QImage m_image;
- QRect m_bounds;
+ QRectF m_bounds;
};
class Q_SVG_PRIVATE_EXPORT QSvgLine : public QSvgNode
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index 0468bbe..dd31965 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -2792,10 +2792,10 @@ static QSvgNode *createImageNode(QSvgNode *parent,
QSvgNode *img = new QSvgImage(parent,
image,
- QRect(int(nx),
- int(ny),
- int(nwidth),
- int(nheight)));
+ QRectF(nx,
+ ny,
+ nwidth,
+ nheight));
return img;
}