Results 1 to 2 of 2

Thread: Modify image to have round corners

  1. #1
    Join Date
    May 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Modify image to have round corners

    Can't find any example of doing it. I need to take ready image and add some radius, also have the rest of the corners transparent.

    Any ideas ?
    Thanks

  2. #2
    Join Date
    May 2011
    Posts
    132
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Modify image to have round corners

    In case somebody will need it.

    Qt Code:
    1. QImage image("image.png");
    2.  
    3. QImage out(image.width(), image.height(), QImage::Format_ARGB32);
    4. out.fill(Qt::transparent);
    5.  
    6. QBrush brush(image);
    7.  
    8. QPen pen;
    9. pen.setColor(Qt::darkGray);
    10. pen.setJoinStyle(Qt::RoundJoin);
    11.  
    12. QPainter painter(&out);
    13. painter.setBrush(brush);
    14. painter.setPen(pen);
    15. painter.drawRoundedRect(0, 0, image.width(), image.height(), 20, 20);
    16.  
    17. out.save("image.png", "PNG", 100);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Image element in round mask
    By olegdim in forum Qt Quick
    Replies: 0
    Last Post: 27th August 2012, 16:03
  2. Replies: 2
    Last Post: 3rd April 2012, 09:49
  3. Replies: 1
    Last Post: 28th December 2010, 10:43
  4. QMenu round corners
    By medved6 in forum Qt Programming
    Replies: 9
    Last Post: 17th September 2010, 23:33
  5. Replies: 32
    Last Post: 30th March 2008, 21:00

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.