Results 1 to 5 of 5

Thread: QSvgRenderer antialiasing

  1. #1
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default QSvgRenderer antialiasing

    Hi,

    I'm trying to write an SVG out to a QPicture and antialias the image while doing so.
    Here's my code.

    However, when I render the QPicture (m_picture), it is aliased...as if the renderhints were ignored.
    Is this expected behavior, or am I doing something wrong?

    Qt Code:
    1. QSvgRenderer* m_renderer = getSvgResource(":/filesystem/file.svg");
    2. QPainter imagePainter(&m_picture);
    3. imagePainter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform, true);
    4. QSvgRenderer* m_renderer->render(&imagePainter, m_bounds);
    To copy to clipboard, switch view to plain text mode 
    Last edited by jonks; 13th August 2009 at 06:40. Reason: spelling error

  2. #2
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: QSvgRenderer antialiasing

    Very strange because the opposite should be hardcoded:

    http://qt.nokia.com/developer/task-t...ntry&id=217793
    It's nice to be important but it's more important to be nice.

  3. #3
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QSvgRenderer antialiasing

    Yes it is very strange.

    The QPicture is eventually draw to screen during a a call to QGraphicsItem:: paint
    (it's drawn using painter->drawPicture(0,0, m_picture);

    The image is not resized/modified at all between the creation code and the QGraphicsItem:: paint code.

    Here's the result of the painting m_picture compared to google chrome.
    - Obviously I've composited the images into one here.


    Note: in this image, the Qt draws QPicture is supposed to be smaller than the one in Chrome (I didn't have time to make them the same size for this demo) - the QT drawn QPicture was NOT resized/scaled/filtered by my code at all.

    Elsewhere in my code the very same QPicture is used in a different context: I also render the QPicture in to a QPixmap for use by QDrag (i.e QDrag::setPixmap).
    I have just noticed that when I do this, the image is NOT antialised.

    So, in summary - here are the two paths the SVG takes through my app:

    SVG file --> QSvgRenderer --> QPicture --> painted into off screen context QPixmap by QGraphicsItem:: paint --> displayed by QDrag == Antialiased (good)

    SVG file --> QSvgRenderer --> QPicture --> painted into screen context by QGraphicsItem:: paint == Aliased (bad)

  4. #4
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QSvgRenderer antialiasing

    OK I nailed it - QPainter::drawPicture is causing the problem.
    If I convert the QPicture to a QPixmap, then the resultant image dawn by QPainter::drawPixmap is antialiased.

    I have no idea why though

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

    Default Re: QSvgRenderer antialiasing

    Guys,

    Sorry but I will bump this issue. I am having the same problem as jonks had. He gave an explanation in his last post but I couldn't get it working. How can I render anti-aliased svg image? Desperately looking for your helps & comments.

    Thank you very much,

Similar Threads

  1. No text antialiasing with OpenGL graphicsview
    By pherthyl in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2009, 22:47
  2. QImage antialiasing
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2008, 19:37
  3. About QSvgRenderer
    By guher in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:21
  4. QSvgRenderer fill rule always evenOdd with gradient
    By mr.costa in forum Qt Programming
    Replies: 0
    Last Post: 24th April 2007, 17:04
  5. Font not Antialiasing
    By ChasW in forum Qt Programming
    Replies: 6
    Last Post: 21st January 2007, 18:12

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.