【问题标题】:Android aapt tool: why convert my png8 to png24Android aapt 工具:为什么将我的 png8 转换为 png24
【发布时间】:2014-01-05 02:48:22
【问题描述】:

我创建了一个 png-8 图像作为九个补丁图像,它只有大约 16K 和 700*1200。 打包后,我检查了结果资源文件,它变成了大约 500K 字节。我打开它,发现它变成了PNG-24。我认为是 AAPT 做到了这一点。有谁知道为什么会这样? 来自文档

http://developer.android.com/guide/topics/graphics/2d-graphics.html#drawables

它只是说它可以通过将真彩色 png 转换为 8 位 png 进行一些优化。我只是不知道为什么会发生相反的情况......

------------更新----------

按照建议,我上传了问题图片

【问题讨论】:

  • 能否提供PNG进行测试?

标签: android png android-resources aapt


【解决方案1】:

经过调查,我发现 png 是 8bit 9patch 的。我发现一篇文章说

// If the image is a 9-patch, we need to preserve it as a ARGB file to make
// sure the pixels will not be pre-dithered/clamped until we decide they are

可以在AAPT源代码Images.cpp中找到

因此 AAPT 将 8 位 png 更改为真彩色。但请记住前提条件:9patch 图像。所以创建一个 8bit 9patch png 不是一个好主意。

【讨论】:

    猜你喜欢
    • 2011-03-12
    • 2014-05-07
    • 2012-01-17
    • 2019-12-24
    • 2010-09-22
    • 2020-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多