gpt4 book ai didi

Android:无损WEBP压缩

转载 作者:行者123 更新时间:2023-12-03 21:40:03 27 4
gpt4 key购买 nike

我正在使用以下代码压缩 WEBP 格式的图像:

bitmap.compress(Bitmap.CompressFormat.WEBP, 100, outputStream)

虽然我使用的是最高质量设置,但看起来图像不是无损压缩的,而是 有损 .
对应于Android开发者文档,应该可以无损压缩WEBP文件:
http://developer.android.com/guide/appendix/media-formats.html
http://developer.android.com/reference/android/graphics/Bitmap.CompressFormat.html

我正在使用 Android 4.4.2 Kitkat 的 Nexus 4 上执行此操作。此外,我在整个项目中使用最高的 SDK。

有没有人知道如何将位图保存为无损 WEBP 图像?

最佳答案

As of Build.VERSION_CODES.Q, a value of 100 results in a file in thelossless WEBP format. Otherwise the file will be in the lossy WEBPformat.


https://developer.android.com/reference/android/graphics/Bitmap.CompressFormat#WEBP
通过将 WEBP_LOSSLESS 指定为压缩格式(或质量为 100 的 WEBP),无损 WebP 压缩似乎仅适用于至少具有 Android Q 的设备。

关于Android:无损WEBP压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22897667/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com