diff --git a/src/imageviewwidget.cpp b/src/imageviewwidget.cpp index 7889a96..1f8b39e 100644 --- a/src/imageviewwidget.cpp +++ b/src/imageviewwidget.cpp @@ -20,6 +20,9 @@ void ImageViewWidget::setImage(const QString &path) QImageReader reader(path); reader.setAutoTransform(true); reader.setDecideFormatFromContent(true); + // Disable the allocation limit so very large images can be viewed. + // The default 128 MB limit rejects high-resolution photos. + reader.setAllocationLimit(0); QImage image = reader.read(); if (!image.isNull()) { diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index fd2b7a6..c6fe438 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -258,6 +258,12 @@ void MainWindow::showPreview(const QModelIndex &index) QImageReader reader(path); reader.setAutoTransform(true); + // Scale during decoding for the preview to avoid the 128 MB allocation limit + QSize fullSize = reader.size(); + if (fullSize.isValid()) { + QSize target = fullSize.scaled(m_previewLabel->size(), Qt::KeepAspectRatio); + reader.setScaledSize(target); + } QImage image = reader.read(); m_previewLabel->setPixmap( diff --git a/src/thumbnailworker.cpp b/src/thumbnailworker.cpp index 9b094ba..5a209ab 100644 --- a/src/thumbnailworker.cpp +++ b/src/thumbnailworker.cpp @@ -20,6 +20,14 @@ void ThumbnailWorker::run() QImageReader reader(m_path); reader.setAutoTransform(true); + // Scale during decoding to avoid hitting the allocation limit + // on very large images (Qt 6 defaults to 128 MB). + QSize fullSize = reader.size(); + if (fullSize.isValid()) { + QSize target = fullSize.scaled(128, 128, Qt::KeepAspectRatio); + reader.setScaledSize(target); + } + QImage image = reader.read(); if (*m_cancelFlag) @@ -28,6 +36,7 @@ void ThumbnailWorker::run() if (!image.isNull()) { // Scale to fit within 128x128 keeping aspect ratio + // (may already be the right size if setScaledSize succeeded) QImage scaled = image.scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation);