QImage weird artifacts when drawing with QPainter
Unsolved
General and Desktop
-
Hi,
Im new to Qt and am currently experimenting with QPainter/Image. Consider the following code:
QImage blankmap; //white image of size 1470*850 blankmap.load("images/maps/blankmap.png"); QImage gray; // gray 10*10 image gray.load("gray.png"); QPainter painter; painter.begin(&blankmap); QRect r(0, 0, 10, 10); for (int i = 0; i < 1470; i += 10) { for (int j = 0; j < 850; j += 10) { r.setX(i); r.setY(j); painter.drawImage(r, gray); } } painter.end(); blankmap.save("map1.png");
My expectation now would be that the resulting image is just gray. However as you can see it has two white stripes. Can someone explain this to me?
-
Your rectangle is wrong. See QRect::setX() and QRect::setY().
-
@Infestor said in QImage weird artifacts when drawing with QPainter:
Is there a functoin that does what i want it to do? At first glance it seems like there is not.
Then you should take a second look. You want to move your rectangle.