Qt5QImageReader奇怪的行为

Qt5 QImageReader Strange Behavior

本文关键字:Qt5QImageReader      更新时间:2023-10-16

我使用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);
    }

当我用Qt5.3.2_MSVC 2013_OpenGl 64位编译它时,我用18000x18000的图像对它进行了测试(感谢美国国家航空航天局哈勃图像…),程序运行没有错误。当我测试相同的程序,但使用Qt5.3.2_MSVC 2013_OpenGl 32位编译时,程序失败,读取器错误为"无法读取图像数据"!

这是Qt中的一个错误,还是Qt文档中没有提到的32位版本的限制?

此大小的映像需要18000*18000*23=1.266GB的连续内存,而在32位系统上,您的程序可能没有这些内存。你可能会发现这对如何将其分割成小块很有帮助。https://forum.qt.io/topic/4270/qimagereader-setcliprect-limitation-on-size-large-image/4