[Interest] Drawing high resolution pixmaps with QBrush (High DPI 2x)

Pavlo Dyachenko ppaveld at yahoo.ie
Thu Nov 5 20:34:49 CET 2015


Hi, I'm trying to draw a high resolution image when device pixel ratio is set to 2x (to display nicely on a 4K monitor).It works fine if I draw a pixmap directly on a painter:
int pixelRatio = 2;QPixmap myImage = ...;auto pxm = myImage.scaled(imgDiameter * pixelRatio, imgDiameter * pixelRatio, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);pxm.setDevicePixelRatio(pixelRatio);painter->drawPixmap(QPoint(xPos, yPos), pxm);
However since I need images to be drawn on top of irregular shapes I use the brush:int pixelRatio = 2;QPixmap myImage = ...;auto oldBrush = painter->brush();auto pxm = myImage.scaled(imgDiameter * pixelRatio, imgDiameter * pixelRatio, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);pxm.setDevicePixelRatio(pixelRatio);QBrush brush(pxm);painter->setPen(Qt::NoPen);painter->setBrush(brush);painter->setBrushOrigin(xPos, yPos);painter->drawEllipse(xPos, yPos, imgDiameter, imgDiameter);painter->setBrush(oldBrush);
When the brush is getting filled it appears that it doesn't adhere to pixmap's devicePixelRatio, so the pixmap inside the shape is twice as big.
Is there something wrong with what I'm doing?
Thanks,Pavlo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151105/6e8bb6c1/attachment.html>


More information about the Interest mailing list