PDA

View Full Version : zooming via QPainter::scale



tuli
24th November 2022, 07:34
Hi,

I have a custom rendered widget I want to zoom, which I can do by calling scale(x,x) on my QPainter before drawing.
This works well, but I do not really understand what is happening tbh, even after reading the source.

Specifically - how does this transformation translate to pixel size? If i render a 10-pixel item without scaling, how many pixels does this item take up on the screen
after calling scale(1.5, 1.5) on the painter?


Thanks.

d_stranz
24th November 2022, 16:39
If i render a 10-pixel item without scaling, how many pixels does this item take up on the screen after calling scale(1.5, 1.5) on the painter?

AFAIK, it should take up a 15 x 15 pixel area. But it depends on whether you are using a cosmetic pen for drawing. If it is a cosmetic pen, then the pen width will not scale but will always be 1 pixel wide. If you are using a solid brush for area fills, then scaling will just fill the larger area. With a textured or gradient brush I don't know what will happen - either the pixels will be scaled or the pattern will be repeated but I don't know which.

If you are scaling an image (pixmap, image, bitmap) the pixels will be expanded and interpolated if appropriate.

tuli
24th November 2022, 18:53
> AFAIK, it should take up a 15 x 15 pixel area.

You are right! Seems I messed something up in my initial attempt. Then I guess it all falls into place nicely. Thanks.