Re: QPixmap scaling question
Come on... :) You draw a diagonal line, scale it to half and expect to see a difference? The line is the same(diagonal). Try drawing something else.
Re: QPixmap scaling question
Thanks Marcel, but whatever I draw I don't see the difference (the picture is not getting smaller when I scale()) - the overall size of the pixmap is unchanged. There must be something else wrong. I've tested this with all kinds of other shapes, too.
Re: QPixmap scaling question
What does pm.size() returns after scaling? It should return (300, 225). If so, then the scaling is successful.
Re: QPixmap scaling question
Hi Marcel. Thanks for helping me.
The scaling does not take place because the 1) pixmap is displayed in original size, and
2) the size as returned by height() and width() has not changed. I put the code below.
Code:
p.setPen(pen);
p.drawLine(0, 0, 600, 450);
pm = pm.scaled(300,225);
xLabel->setNum(pm.width());
yLabel->setNum(pm.height());
pixmapLabel->setPixmap(pm);
P.S. I'm drawing a straight line here in order to be able to easily tell cropping from rescaling. If cropping takes place, the line is no longer perfect diagonal. That's why I chose to draw a line in this test code.
Re: QPixmap scaling question
I think this might be because the painter is still opened on the pixmap when you scale it.
Try calling p.end() before scaling the pixmap.