2
votes

I test a simple code using QImageReader

    scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);
    QPixmap pixmap;
    QImageReader reader("hubble.tif");
    reader.setClipRect(QRect(0,0,8000,8000));
    QImage img = reader.read();
    if (img.isNull())
        qDebug() << reader.errorString();
    else
    {
        pixmap = QPixmap::fromImage(img);
        scene->addPixmap(pixmap);
    }

When I compiled it with Qt5.3.2_MSVC 2013_OpenGl 64bit and I tested it with an image 18000x18000 (thanks Nasa Hubble Image...), the program work without error. When I test the same program but compiled with Qt5.3.2_MSVC 2013_OpenGl 32bit, the program fail with reader's error "Unable to read image data" !

Is this a bug in Qt or just a limitation of 32bit version that not mentionned in Qt Documentation ?

1
I've had trouble with large .tif files on Qt5.4.0_MSVC 2010_OpenGL 32bit also. Not sure what causes it though...owacoder
I convert this image to png format but I have the same behavior ! I think is in related with memory allocation problem but no informations is mentionned in Qt documentaion. An other thing is that QImageReader, normally, don't load image in memory but I think it do that when reading !Mohamed Hamzaoui

1 Answers

0
votes

An image that size needs 18000 * 18000 * 23 = 1.266GB of contiguous memory, which on a 32 bit system your program might not have. You might find this helpful in how to split it up into smaller chunks. https://forum.qt.io/topic/4270/qimagereader-setcliprect-limitation-on-size-large-image/4