Results 1 to 3 of 3

Thread: QTransform Pixel Issue

  1. #1
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTransform Pixel Issue

    Hello peeps.

    I got an issue with the usage of QTransform. As you can se in the attachment the pixmap after the transform is ugly and I cant figure out why this is.

    The code I use is
    Qt Code:
    1. void CDIPointer::paintEvent(QPaintEvent *)
    2. {
    3. initMyResource();
    4. QPainter boolPainter(this);
    5.  
    6. qreal width = m_pointer.size().width();
    7. qreal height = m_pointer.size().height();
    8.  
    9. QTransform transform;
    10. transform.translate(size().width()/2, size().height()/2);
    11. transform.rotate(m_rotation);
    12. transform.translate(-size().width()/2, -size().height()/2);
    13. transform.scale(size().width() / width, size().height() / height);
    14.  
    15. boolPainter.setTransform(transform);
    16.  
    17. //boolPainter.setTransform(QTransform().translate(size().width()/2, size().height()/2)
    18. // .rotate(m_rotation).translate(-size().width()/2, -size().height()/2));
    19. boolPainter.drawPixmap(0, 0, m_pointer);
    20. boolPainter.end();
    21. }
    To copy to clipboard, switch view to plain text mode 

    Can anybody see how I can improve this so the quality stays the same?
    Attached Images Attached Images

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QTransform Pixel Issue

    boolPainter->setRenderHint(QPainter::Antialiasing);

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

    meazza (21st June 2011)

  4. #3
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTransform Pixel Issue

    Quote Originally Posted by Rachol View Post
    boolPainter->setRenderHint(QPainter::Antialiasing);
    Did not fix the issue. Also tried the boolPainter.setRenderHint(QPainter::HighQualityAnt ialiasing.


    Added after 8 minutes:


    Fixed it. Thank you Rachol for pointing me in the right direction.

    Qt Code:
    1. boolPainter.setRenderHint(QPainter::SmoothPixmapTransform);
    To copy to clipboard, switch view to plain text mode 
    Last edited by meazza; 21st June 2011 at 10:09.

Similar Threads

  1. Using QTransform to map the mouse
    By Cruz in forum Qt Programming
    Replies: 0
    Last Post: 22nd February 2010, 08:47
  2. QTransform()
    By mkind in forum Newbie
    Replies: 0
    Last Post: 19th February 2010, 21:45
  3. GraphicsItemChange and QTransform
    By ct-xuyaojun in forum Qt Programming
    Replies: 0
    Last Post: 28th September 2009, 09:16
  4. QPixmap pixel by pixel ?
    By tommy in forum Qt Programming
    Replies: 19
    Last Post: 3rd December 2007, 22:52
  5. QTransform vs QMatrix
    By maverick_pol in forum Qt Programming
    Replies: 7
    Last Post: 4th October 2007, 10:53

Tags for this Thread

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.