QSvgRenderer antialiasing seems not working



  • Hi all,

    I have an svg image and I need to scale it using QPainter & QImage. The final image is redered using QSvgRenderer. However, there is no change at the output image even though I apply anti aliasing. Could you please guide me to find the mistake?
    @
    void DrawImage(QImage &image)
    {
    QPainter *myQPainter = new QPainter(&image);
    QSvgRenderer *mySvgImg = new QSvgRenderer("svgimage");

    //Some scaling stuff

    myQPainter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
    
    QRect myrectangle(500, 500, 600, 600);
    mySvgImg ->render(myQPainter,myrectangle);
    
    myQPainter ->end();
    

    }@


  • Moderators

    You're setting the antialiasing flags on myQPainter and then use pnt to render. Are these the same thing?

    As a side note - the end() method is called by the QPainter's destructor (and I don't see a delete there so you have a memory leak btw.), so you usually don't need to call it explicitly. It is more common to crate the local painter on the stack to let it automatically release any resources and be gone at the end of the scope.



  • [quote author="Krzysztof Kawa" date="1364552220"]You're setting the antialiasing flags on myQPainter and then use pnt to render. Are these the same thing?

    As a side note - the end() method is called by the QPainter's destructor (and I don't see a delete there so you have a memory leak btw.), so you usually don't need to call it explicitly. It is more common to crate the local painter on the stack to let it automatically release any resources and be gone at the end of the scope.[/quote]

    That's my bad. I replaced some of the variable names to make it more readable when posting but forgot the pnt. I have already corrected my first post.
    Yes I use end(); also but didn't post here as well.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.