Qt增加webp格式支持

Webp 是一种图片文件格式,能在相同质量的情况下比 PNG 文件尺寸小巧。

Chrome 应用商店图片已全部转换为 WebP 格式

YY(基于Qt开发)也已经把图片格式换成webp了

http://img2webp.net/ 这个网站 将 jpg/png/gif 拖拽进入就可以转换了,转换后的 WebP 文件会在IMG2WebP 上保存一天。

安装默认的参数来看, 转换后的webp图片体积一般在原图的1/10到1/3. 这是非常可观的. 

唯一的缺点就是支持平台少, 目前只有chrome支持

QT5.3 已经纳入webp. 

Qt5.3之前的版本如果想要支持webp, 则需要自己编译. 

参考 Qt bug report

Change I9409e894: Added webp image format plugin

 

https://codereview.qt-project.org/#change,56026

需要在qt-src-5.1.1\qtimageformats 下增加这些文件

config.tests/libwebp/libwebp.cpp        51 lines    Side-by-Side    Unified
config.tests/libwebp/libwebp.pro        6 lines    Side-by-Side    Unified
qtimageformats.pro        +1, -0    Side-by-Side    Unified
src/plugins/imageformats/imageformats.pro        +4, -1    Side-by-Side    Unified
src/plugins/imageformats/webp/main.cpp        98 lines    Side-by-Side    Unified
src/plugins/imageformats/webp/qwebphandler.cpp        213 lines    Side-by-Side    Unified
src/plugins/imageformats/webp/qwebphandler_p.h        86 lines    Side-by-Side    Unified
src/plugins/imageformats/webp/webp.json        4 lines    Side-by-Side    Unified
src/plugins/imageformats/webp/webp.pro        16 lines    Side-by-Side    Unified
tests/auto/auto.pro        +2, -1    Side-by-Side    Unified
tests/auto/webp/images/kollada.png                  new    Unified
tests/auto/webp/images/kollada.webp                  new    Unified
tests/auto/webp/images/kollada_lossless.webp                  new    Unified
tests/auto/webp/images/lena.jpg                  new    Unified
tests/auto/webp/images/lena.webp                  new    Unified
tests/auto/webp/images/lena_lossless.webp                  new    Unified
tests/auto/webp/tst_qwebp.cpp        119 lines    Side-by-Side    Unified
tests/auto/webp/webp.pro        8 lines    Side-by-Side    Unified
tests/auto/webp/webp.qrc

这些文件我打包了一份. http://download.csdn.net/detail/lingdhox/7303513

你也可以去Qt的git上下载这些文件, 然后覆盖过去

注意:

  我编译的版本是5.1.1, 如果是其他版本的话, 请不要直接覆盖. 

最后, 执行下 nmake module-qtimageformats 

 

ps: 在configure时, 可以加上参数 -no-plugin-manifests, 就不会产生manifests文件

ps2: webkit 对webp的支持写在features.prf中, config_libwebp: WEBKIT_CONFIG += use_webp

posted on 2014-05-06 15:11  一 水  阅读(2008)  评论(0编辑  收藏  举报

导航