1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

MaskablePixmapWidget::getPixmap: return the masked pixmap

This commit is contained in:
krepa098 2014-10-05 14:36:07 +02:00
parent b487fddf99
commit 8e664b5ff7
2 changed files with 6 additions and 5 deletions

View File

@ -19,6 +19,7 @@
MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName)
: QWidget(parent)
, renderTarget(size)
, backgroundColor(Qt::white)
, clickable(false)
{
@ -106,17 +107,16 @@ void MaskablePixmapWidget::setPixmap(const QPixmap &pmap)
QPixmap MaskablePixmapWidget::getPixmap() const
{
return pixmap;
return renderTarget;
}
void MaskablePixmapWidget::paintEvent(QPaintEvent *)
{
QPixmap tmp(width(), height());
tmp.fill(Qt::transparent);
renderTarget.fill(Qt::transparent);
QPoint offset((width() - pixmap.size().width())/2,(height() - pixmap.size().height())/2); // centering the pixmap
QPainter painter(&tmp);
QPainter painter(&renderTarget);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.fillRect(0,0,width(),height(),backgroundColor);
painter.drawPixmap(offset,pixmap);
@ -125,7 +125,7 @@ void MaskablePixmapWidget::paintEvent(QPaintEvent *)
painter.end();
painter.begin(this);
painter.drawPixmap(0,0,tmp);
painter.drawPixmap(0,0,renderTarget);
}
void MaskablePixmapWidget::mousePressEvent(QMouseEvent*)

View File

@ -42,6 +42,7 @@ protected:
private:
QPixmap pixmap;
QPixmap mask;
QPixmap renderTarget;
QSize size;
QString maskName;
QColor backgroundColor;