fix: use format() to check if we support such format
This commit is contained in:
parent
5495fa06d3
commit
eb648e3112
|
@ -39,8 +39,10 @@ void GraphicsView::showFileFromUrl(const QUrl &url, bool doRequestGallery)
|
||||||
QImageReader imageReader(filePath);
|
QImageReader imageReader(filePath);
|
||||||
imageReader.setAutoTransform(true);
|
imageReader.setAutoTransform(true);
|
||||||
imageReader.setDecideFormatFromContent(true);
|
imageReader.setDecideFormatFromContent(true);
|
||||||
QImage::Format imageFormat = imageReader.imageFormat();
|
// Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
|
||||||
if (imageFormat == QImage::Format_Invalid) {
|
// So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file.
|
||||||
|
// QImage::Format imageFormat = imageReader.imageFormat();
|
||||||
|
if (imageReader.format().isEmpty()) {
|
||||||
showText(tr("File is not a valid image"));
|
showText(tr("File is not a valid image"));
|
||||||
} else {
|
} else {
|
||||||
showImage(QPixmap::fromImageReader(&imageReader));
|
showImage(QPixmap::fromImageReader(&imageReader));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user