Quantcast
Channel: Active questions tagged qpainter - Stack Overflow
Viewing all articles
Browse latest Browse all 49

How to keep QPixamp quality in QPainter::drawPixmap when QPainter::scale(x,y) is used?

$
0
0

I am using QWidget and its paintEvent.Im using QPainter::scale(zoom,zoom) to scale background images on the widget.Then I want to paint some foreground icons and keep their size the same all the time while preserving quality.

The problem is that even though the QPixamp is kept the same size, its quality decrades.The bigger the "zoom" the bigger the loss in quality.

Minimal code example:

void myPainter::paintEvent(QPaintEvent *){ QPainter p(this); p.scale(myZoom,myZoom) . . . double tagSize = t->icon_->height() / zoom; QPoint tagpoint = rect().center(); p.drawPixmap(tagpoint, t->icon_->scaledToHeight(tagSize,Qt::SmoothTransformation));}

I Used drawPixamp with scaled QPixmap.I expected for the QPixamp quality to not decrade but stay the same.

EDIT:(a partial solution)To keep the pixmap quality it was possible tounzoom,draw,zoom to keep the image quality good and image samesize without resizing.

p.scale(1/zoom,1/zoom);p.drawPixmap(tagpoint * zoom, *t->icon_);p.scale(zoom,zoom);

This forced new calculation to the tag point the keep the position same, but it seems to work after calculating the position and taking the zoom to account in there.


Viewing all articles
Browse latest Browse all 49

Trending Articles