PDA

View Full Version : Huge image tearing / disappearing on extreme scaling



quimnuss
2nd May 2018, 18:24
I have a big image of 7589x5537 that I put in a scene as a QPixmapGraphicsItem.

If I scale the QGraphicsView to 14.2318 and rotate it -35 degrees, the render of the pixmap starts behaving weirdly; tearing or completely disappearing.

This happens also at other rotations and scales, but only if they are big scaling of more than 14.

I've read about X11 limitations but I'm on Windows.

I'm on Qt 5.5

I've tested changing the content of the image to a bucketfill of tree pattern, exactly the same behaviour. The image is indexed, but with a RGB I have the same issue.

Anybody has a clue why this happens and how to fix it? Is the problem reproducible?



#include <QtWidgets>

int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QFileInfo imagefile("tree_map.png");

QPixmap imagepm(imagefile.absoluteFilePath());

QGraphicsPixmapItem* item = new QGraphicsPixmapItem(imagepm);
item->setTransformationMode(Qt::FastTransformation);
QGraphicsScene* scene = new QGraphicsScene;
scene->addItem(item);

QGraphicsView* view = new QGraphicsView(scene);
view->rotate(-35);
view->scale(14.2318,14.2318);
view->show();
return a.exec();
}



I'm not sure the image is correctly handled by Qt Forums and, although I believe anybody could create it again, you will also find it here:

https://www.dropbox.com/s/y4ibs7p1j0r4sfp/tree_map.jpg?dl=0

quimnuss
3rd May 2018, 10:02
I haven't found how to edit the previous post in the forum. Here a MWE example that auto-generates the image:



#include <QtWidgets>

int main(int argc, char *argv[]) {
QApplication a(argc, argv);

unsigned int w = 7589;
unsigned int h = 5537;

QImage image(w, h, QImage::Format_ARGB32);
for(unsigned int j = 0; j < h; j++)
{
for(unsigned int i = 0; i < w; i++)
{
QRgb rgb = qRgb(i%255,j%255,(i+j)%255);
image.setPixel(i, j, rgb);
}
}

QPixmap imagepm = QPixmap::fromImage(image);

QGraphicsPixmapItem* item = new QGraphicsPixmapItem(imagepm);
item->setTransformationMode(Qt::FastTransformation);
QGraphicsScene* scene = new QGraphicsScene;
scene->addItem(item);

QGraphicsView* view = new QGraphicsView(scene);
view->rotate(-35);
view->scale(14.2318,14.2318);
view->show();
return a.exec();
}