PDA

View Full Version : Modify image to have round corners



migel
31st August 2012, 09:47
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

migel
4th September 2012, 11:38
In case somebody will need it.



QImage image("image.png");

QImage out(image.width(), image.height(), QImage::Format_ARGB32);
out.fill(Qt::transparent);

QBrush brush(image);

QPen pen;
pen.setColor(Qt::darkGray);
pen.setJoinStyle(Qt::RoundJoin);

QPainter painter(&out);
painter.setBrush(brush);
painter.setPen(pen);
painter.drawRoundedRect(0, 0, image.width(), image.height(), 20, 20);

out.save("image.png", "PNG", 100);