Hi,
I have to design a canvas where users can drag & drop images as background and paint by tablet.
I use view/scene to drag & drop the background images. After switching mode, user sketch can be captured in a pixmap after tablet events.
However, how can I blend the pixmap (user sketch) into the background images ?
class TabletCanvas : public QGraphicsView
To copy to clipboard, switch view to plain text mode
void TabletCanvas
::drawForeground(QPainter *painter,
const QRectF
& rect
) {
QPixmap _m
(pixmap
);
// the pixmap keeps user sketch //_m.setMask(pixmap.createMaskFromColor(Qt::white, Qt::MaskInColor));
_m.setAlphaChannel(pixmap.createMaskFromColor(Qt::white, Qt::MaskOutColor));
painter->drawPixmap(0, 0, _m);
}
void TabletCanvas::drawForeground(QPainter *painter, const QRectF& rect)
{
QPixmap _m(pixmap); // the pixmap keeps user sketch
//_m.setMask(pixmap.createMaskFromColor(Qt::white, Qt::MaskInColor));
_m.setAlphaChannel(pixmap.createMaskFromColor(Qt::white, Qt::MaskOutColor));
painter->drawPixmap(0, 0, _m);
}
To copy to clipboard, switch view to plain text mode
The above code works like to "paste" sketch on the images.
fig2.png
I want to blend the sketch and 'background' image pieces.
How to do it ?
1. Can I get the scene-coordinate pixamap in QGraphicsView:aintEvnet() or drawForeground() ?
2. Or the user sketch pixmap should be another item in scene ?
Please give me some suggestions, thank you
Bookmarks