Android aapt tool: why convert my png8 to png24

658 views Asked by At

I create an png-8 image as the nine-patch image, which is only about 16K with 700*1200. After packaging, i checked the result resource file, it changed to about 500K bytes. I opened it and found it is changed to PNG-24. I think it is the AAPT that has done this. Does anyone has any clue why this happens? From the doc

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

it only say it could do some optimization with converting true color png to an 8-bit one. I just dont know why the contrary happened....

------------------------UPDATE---------------------

as suggested, i upload the problomatic image

enter image description here

1

There are 1 answers

0
mianlaoshu On

After investiagtion, i found the png is a 8bit 9patch one. I found an article said

// 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

It can be found in the AAPT source code Images.cpp

So AAPT changed the 8 bit png to the true color one. But remember the precondition: 9patch image. So it's not a good idea to create a 8bit 9patch png.