Skip to content

Commit

Permalink
fix: support multi frame image load
Browse files Browse the repository at this point in the history
As title.

Log: Support multi frame image load.
Influence: quickprint
  • Loading branch information
rb-union committed Oct 25, 2024
1 parent 9e610b0 commit ed671d7
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions libimageviewer/quickprint/printimageloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,23 +260,25 @@ bool PrintImageLoader::loadImageData(PrintImageData::Ptr &imagePtr)
}

try {
if (s_SingleFrame == imagePtr->frame) {
QImageReader reader(imagePtr->filePath);
// jumpToImage 可能返回 false, 但数据正常读取
QImageReader reader(imagePtr->filePath);
// jumpToImage 可能返回 false, 但数据正常读取
if (s_SingleFrame != imagePtr->frame) {
reader.jumpToImage(imagePtr->frame);
if (!reader.canRead()) {
qWarning() << QString("Load multi frame image failed(jump to image): %1").arg(reader.errorString());
imagePtr->state = ContentError;
return false;
}
}

if (!reader.canRead()) {
qWarning() << QString("Load multi frame image failed(jump to image): %1").arg(reader.errorString());
imagePtr->state = ContentError;
return false;
}

imagePtr->data = reader.read();
if (imagePtr->data.isNull()) {
qWarning() << QString("Load multi frame image failed: %1").arg(reader.errorString());
imagePtr->state = ContentError;
return false;
}
imagePtr->data = reader.read();
if (imagePtr->data.isNull()) {
qWarning() << QString("Load multi frame image failed: %1").arg(reader.errorString());
imagePtr->state = ContentError;
return false;
}

} catch (const std::exception &e) {
// 图片读取,考虑未界定异常
qCritical() << qPrintable("Exception: load image failed!") << qPrintable(e.what());
Expand Down

0 comments on commit ed671d7

Please sign in to comment.