Artefact on upper rounded corner of image
Solved
General and Desktop
-
I draw alpha background on empty image with rounded corners. After draw small images with CompositionMode_SourceIn, but this do and with images created from fill rect.
I am using qt 6.1.2 and was trying 5.15.2, result are same
code to reproduce#include <QPainter> #include <QPainterPath> void drawAlpha(QImage &image, int width, int height); void drawSimple(QVector<QImage> &images, QImage &im, int width, int height); void createImage(QVector<QImage> &images, int width, int height); int main(int , char **) { QVector<QImage> images{}; createImage(images, 96, 96); drawSimple(images, images[0], 220, 285); drawSimple(images, images[0], 300, 150); images[1].save("../test1.png", "PNG"); images[2].save("../test2.png", "PNG"); return 0; } void drawAlpha(QImage &image, int width, int height) { QPainter paint{ &image }; paint.setRenderHint(QPainter::Antialiasing); paint.setPen(Qt::NoPen); paint.fillRect(0, 0, width, height, Qt::transparent); QPainterPath path{}; path.addRoundedRect(0, 0, width, height, 25, 25); paint.fillPath(path, Qt::red); paint.end(); } void drawSimple(QVector<QImage> &images, QImage &im, int width, int height) { QImage img{width, height, QImage::Format_RGBA8888}; drawAlpha(img, width, height); QPainter paint{ &img }; paint.setRenderHint(QPainter::Antialiasing); paint.setCompositionMode(QPainter::CompositionMode_SourceIn); for (int y = 0; y < height; y += im.height()) { for (int x = 0; x < width; x += im.width()) { paint.drawImage(x, y, im); } } paint.end(); images.append(img); } void createImage(QVector<QImage> &images, int width, int height) { QImage image { width, height, QImage::Format_RGB888 }; QPainter paint{ &image }; paint.fillRect(0, 0, image.width(), image.height(), Qt::black); paint.end(); images.append(image); }