Windows Qt中支持heic 图片显示

安装vcpkg:

git clone https://github.com/microsoft/vcpkg

执行脚本:

.\vcpkg\bootstrap-vcpkg.bat

在安装之前如果需要指定vs的编译器, 在如下文件中做更改, 我指定的是用vs2019编译的:

D:\vcpkg\vcpkg\triplets

增加了

复制代码
set(VCPKG_PLATFORM_TOOLSET "v142")
set(VCPKG_DEP_INFO_OVERRIDE_VARS "v142")

安装Libheif

复制代码
        指定安装(编译)64位库
        .\vcpkg\vcpkg install libheif:x64-windows

        #指定安装(编译)32位库
        .\vcpkg\vcpkg install libheif:x86-windows

成功后在如下目录中生成64位和32位的

编写qt插件(这里有我自已写的demo, vs2019 32位的)

https://download.csdn.net/download/uVarAndMethod/89302876?spm=1001.2014.3001.5503

生成的debug和release的dll放入qt安装目录下 Qt\5.15.2\msvc2019\plugins\imageformats中, 如下图

这样做完之后, 加载heic图片

复制代码
import QtQuick 2.15
import QtQuick.Window 2.15

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")
    Image{
        anchors.centerIn: parent
        source: "file:///C:\\Users\\Administrator\\Desktop\\wget\\311.HEIC"
    }
}

然后, 再把 vcpkg中编译好的dll放入当前可执行文件目录下,运行即可显示

运行图片:

相关推荐
xcyxiner4 小时前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner20 小时前
DicomViewer (后台线程处理文件)4
qt
xcyxiner1 天前
DicomViewer (添加模型类)3
qt
xcyxiner2 天前
DicomViewer (目录调整) 2
qt
xcyxiner2 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
clint4563 天前
C++进阶(1)——前景提要
c++
夜悊3 天前
C++代码示例:进制数简单生成工具
c++
郝学胜_神的一滴3 天前
CMake 021: IF 条件判据详诠
c++·cmake
_wyt0014 天前
洛谷 B3930 [GESP202312 五级] 烹饪问题 题解
c++·gesp
qq_369224334 天前
Windows全系通用!ntdll.dll文件丢失、报错、闪退问题的完整排查与修复教程
windows·dll·dll修复·dll丢失·dll错误