From c6d2663e7b12c42b883b9c1b3d1c76bee616e0f1 Mon Sep 17 00:00:00 2001 From: ut001910 Date: Tue, 1 Apr 2025 16:43:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=9F=A5=E7=9C=8B750?= =?UTF-8?q?=20X=207882=E5=B0=BA=E5=AF=B8=E5=9B=BE=E7=89=87=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复查看750 X 7882尺寸图片问题 Bug: https://pms.uniontech.com/bug-view-310713.html Log: 修复查看750 X 7882尺寸图片问题 --- libimageviewer/unionimage/unionimage.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libimageviewer/unionimage/unionimage.cpp b/libimageviewer/unionimage/unionimage.cpp index 455b0d8a..49e89016 100644 --- a/libimageviewer/unionimage/unionimage.cpp +++ b/libimageviewer/unionimage/unionimage.cpp @@ -253,6 +253,12 @@ UNIONIMAGESHARED_EXPORT bool loadStaticImageFromFile(const QString &path, QImage QImageReader reader; QImage res_qt; reader.setFileName(path); + //当不能读取数据时,设置以内容判断格式进行加载,这样可以避免后缀名修改后文件无法打开的情况 + if (!reader.canRead()) { + reader.setAutoDetectImageFormat(true); //控制是否通过内容识别格式 + reader.setDecideFormatFromContent(true); // 根据内容识别格式 + reader.setFileName(path); //必须重新设置一下文件,才能触发内部加载方式的切换 + } if (format_bar.isEmpty()) { reader.setFormat(file_suffix_lower.toLatin1()); } else {