Results 1 to 3 of 3

Thread: QSvgRenderer onto QImage with antialiasing

  1. #1
    Join Date
    Jul 2013
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QSvgRenderer onto QImage with antialiasing

    Hi,

    I have a QImage and I draw an svg image onto. Here is my simplified code:

    Qt Code:
    1. void WP::DrawImage(QImage &mImage)
    2. {
    3. QPainter *pPainter = new QPainter(&mImage);
    4. QSvgRenderer *svgImg = new QSvgRenderer(linkToSvgImage);
    5.  
    6. QRect rct(0, 0, 500, 500);
    7. svgImg->render(pPainter, rct);
    8. pPainter->setRenderHints(QPainter::Antialiasing, true);
    9. pPainter->end();
    10.  
    11. delete svgImg;
    12. delete pPainter;
    13. }
    To copy to clipboard, switch view to plain text mode 
    However, the painted image is aliased and I want to have an anti-aliased image. I have tried setRenderHints() but didn’t help. Could anyone help me about how to implement it?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSvgRenderer onto QImage with antialiasing

    I would start by rendering the SVG after you set the Antialiasing hint.

    BTW: neither the QPainter nor the QSvgRenderer needs to allocated on the heap.

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

    dolevo (19th July 2013)

  4. #3
    Join Date
    Jul 2013
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QSvgRenderer onto QImage with antialiasing

    Quote Originally Posted by ChrisW67 View Post
    I would start by rendering the SVG after you set the Antialiasing hint.

    BTW: neither the QPainter nor the QSvgRenderer needs to allocated on the heap.
    I have already tried it but no joy.

    I have found another thread in this forum http://www.qtcentre.org/threads/2327...r-antialiasing
    However, I didn't get what he meant. I did try painting onto QPixmap but the image is still aliased.

    Any help?

Similar Threads

  1. QSvgRenderer antialiasing
    By jonks in forum Qt Programming
    Replies: 4
    Last Post: 19th July 2013, 09:39
  2. QPainter Antialiasing for QImage
    By mupilz in forum Qt Programming
    Replies: 1
    Last Post: 14th February 2012, 17:51
  3. QSvgRenderer and QWidget
    By lexqqq in forum Qt Programming
    Replies: 0
    Last Post: 31st October 2010, 11:51
  4. QImage antialiasing
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2008, 19:37
  5. About QSvgRenderer
    By guher in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:21

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.