Results 1 to 4 of 4

Thread: Resizing a pixmap without losing quality

  1. #1
    Join Date
    Jul 2015
    Posts
    20
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Resizing a pixmap without losing quality

    I want to resize a pixmap and not lose the quality of image. If you make something bigger than the source size is, it will obviously lose quality, no doubt.
    However, what I want to do is resize like that:
    100% -> 25% -> 100%
    Using QPixmap.scaled unfortunately loses the quality and the final image looks terrible, even though it's the exact same size it was when loaded.
    Can I make it somehow else rather than saving file's path and loading pixmap from file every time I enlarge it after making it smaller?

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Resizing a pixmap without losing quality

    Keep two QPixmap instances around: a scaled one that you display, and the original one from which you recompute each scaled version.

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

    Grzyboo (4th August 2015)

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Resizing a pixmap without losing quality

    Just keep the original image.

    scaled() doesn't affect the image it is being called on, it returns the scaled version as a new image.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    Grzyboo (4th August 2015)

  6. #4
    Join Date
    Jul 2015
    Posts
    20
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Resizing a pixmap without losing quality

    I'm resizing QLabel widget's image. Seems like I need to save an original image for every widget.

Similar Threads

  1. Replies: 0
    Last Post: 11th June 2015, 15:43
  2. Qt + DirectFB == Windows Losing Focus
    By Brandybuck in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 15th October 2014, 20:37
  3. Replies: 0
    Last Post: 8th October 2011, 11:35
  4. Using StyleSheet Without Losing 3D Effects
    By metdos in forum Qt Programming
    Replies: 1
    Last Post: 31st August 2009, 10:20
  5. 'Losing' sockets in Qt torrent example / QTcpServer
    By Kumosan in forum Qt Programming
    Replies: 2
    Last Post: 14th August 2007, 18:23

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.