Quantcast
Viewing latest article 1
Browse Latest Browse All 57

QPainter::drawLine has problem in Large image's width

Recently, I had a problem in my application (So I provided a mini example of the problem) that I faced when creating large-scale images, and when I looked at the output image, it was not fully drawn! I don't know why, so I created a mini-example of that.

#include <QGuiApplication>#include <QPainter>#include <QPixmap>static QPixmap imageTest(int width, int height, QColor const &color) {  static constexpr auto VERTICAL_PADDING = 2;  QPixmap pixmap(width, height);  pixmap.fill(Qt::transparent);  QPainter painter(&pixmap);  painter.setRenderHint(QPainter::Antialiasing);  QPen pen(color);  double const widthF = 1.0;  pen.setWidthF(widthF);  painter.setPen(pen);  for (int i = 0; i < width; ++i) {    QPointF p1(i, 94.9445); // mini example assume fixed height    QPointF p2(i, 167.055); // mini example consider fixed height    painter.drawLine(p1, p2);  }  painter.end();  return pixmap;}int main(int argc, char *argv[]) {  QGuiApplication app(argc, argv);  auto image = imageTest(211'459, 262, Qt::GlobalColor::green);  image.save("testFile.png", "PNG");  app.quit();  return 0;}

the result of image , is something like this:

Image may be NSFW.
Clik here to view.
enter image description here

I also  tested that with other approaches, like drawLines and fillRect, but it didn't help me. What's the problem?


Viewing latest article 1
Browse Latest Browse All 57

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>