我使用 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 的图像测试它时(感谢 Nasa Hubble Image ...),程序运行没有错误。 当我测试同一个程序但使用 Qt5.3.2_MSVC 2013_OpenGl 32 位编译时,程序失败并出现读者错误“无法读取图像数据”!
这是 Qt 中的错误还是只是 Qt 文档中未提及的 32 位版本的限制?
最佳答案
大小需要 18000 * 18000 * 23 = 1.266GB 连续内存的图像,在 32 位系统上您的程序可能没有。您可能会发现这有助于将其拆分为更小的 block 。 https://forum.qt.io/topic/4270/qimagereader-setcliprect-limitation-on-size-large-image/4
关于c++ - Qt5 QImageReader 奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34180609/