Add convenient QImage image() getter in SVG

This commit is contained in:
David Edmundson 2014-02-20 12:09:59 +01:00
parent 318560c8c2
commit 9459ed1f02
2 changed files with 22 additions and 0 deletions

View File

@ -668,6 +668,13 @@ QPixmap Svg::pixmap(const QString &elementID)
}
}
QImage Svg::image(const QString &elementID)
{
return pixmap(elementID).toImage();
}
void Svg::paint(QPainter *painter, const QPointF &point, const QString &elementID)
{
QPixmap pix((elementID.isNull() || d->multipleImages) ? d->findInCache(elementID, size()) :

View File

@ -94,6 +94,21 @@ class PLASMA_EXPORT Svg : public QObject
*/
Q_INVOKABLE QPixmap pixmap(const QString &elementID = QString());
/**
* Returns an image of the SVG represented by this object.
*
* The size of the image will be the size of this Svg object (size())
* if containsMultipleImages is @c true; otherwise, it will be the
* size of the requested element after the whole SVG has been scaled
* to size().
*
* @param elementId the ID string of the element to render, or an empty
* string for the whole SVG (the default)
* @return a QPixmap of the rendered SVG
*/
Q_INVOKABLE QImage image(const QString &elementID = QString());
/**
* Paints all or part of the SVG represented by this object
*