Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support multi frame image load #148

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading