Results 1 to 3 of 3

Thread: zooming via QPainter::scale

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default zooming via QPainter::scale

    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.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: zooming via QPainter::scale

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    tuli (24th November 2022)

  4. #3
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: zooming via QPainter::scale

    > 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.

Similar Threads

  1. Replies: 1
    Last Post: 19th November 2014, 07:48
  2. Replies: 2
    Last Post: 26th December 2012, 02:03
  3. Replies: 2
    Last Post: 21st February 2011, 13:46
  4. QPainter performance for zooming and draw...
    By Programm3r in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2010, 11:29
  5. Replies: 0
    Last Post: 3rd February 2009, 14:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.