diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-28 10:24:32 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-29 06:42:31 (GMT) |
commit | 72debacc7f57b9ea9115e549170341a9ad11bf0f (patch) | |
tree | 798a7bbf7dc4bc376a53b8f705d52e18f6dd26f4 /src/gui/graphicsview/qgraphicsitem.cpp | |
parent | 854acb3478651312dbe84d9b4ef971b46485fe1f (diff) | |
download | Qt-72debacc7f57b9ea9115e549170341a9ad11bf0f.zip Qt-72debacc7f57b9ea9115e549170341a9ad11bf0f.tar.gz Qt-72debacc7f57b9ea9115e549170341a9ad11bf0f.tar.bz2 |
Add QGraphicsEffectSource::pixmap.
We need a convenient way of getting the pixmap representation of the
source.
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index b46abd4..425031f 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -9944,6 +9944,33 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) info->widget, info->opacity, 0, info->wasDirtySceneTransform, info->drawItem); } +QPixmap QGraphicsItemEffectSourcePrivate::pixmap(bool deviceCoordinates, QPoint *offset) const +{ + const QRectF sourceRect = boundingRect(deviceCoordinates); + const QRect effectRect = item->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect(); + if (offset) + *offset = sourceRect.toAlignedRect().topLeft(); + + const QTransform translateTransform = QTransform::fromTranslate(-effectRect.x(), + -effectRect.y()); + QTransform effectTransform = deviceCoordinates ? translateTransform + : info->transformPtr->inverted(); + if (!deviceCoordinates) + effectTransform *= translateTransform; + *info->transformPtr *= effectTransform; + + QPixmap pixmap(effectRect.size()); + pixmap.fill(Qt::transparent); + QPainter pixmapPainter(&pixmap); + pixmapPainter.setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing); + + QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func(); + scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, info->exposedRegion, + info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, + info->drawItem); + return pixmap; +} + bool QGraphicsItemEffectSourcePrivate::drawIntoPixmap(QPixmap *pixmap, const QPoint &offset) { QPoint effectOffset(offset); @@ -9969,7 +9996,7 @@ bool QGraphicsItemEffectSourcePrivate::drawIntoPixmap(QPixmap *pixmap, const QPo pixmapPainter.setRenderHints(QPainter::SmoothPixmapTransform | QPainter::Antialiasing); QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func(); scened->draw(item, &pixmapPainter, &viewTransform, info->transformPtr, &exposedRegion, - info->widget, info->opacity, &effectOffset, info->wasDirtySceneTransform, + info->widget, info->opacity, 0, info->wasDirtySceneTransform, info->drawItem); return true; } |