Obfuscating PNG banding solutions

I am having problems grouping PNG files. Digging into a problem led to two solutions. Both make sense individually, but together they do not. The solutions I discovered are:

1) Move the PNG file to the "raw" folder. This prevents the AAPT from “optimizing” the image, resulting in strapping.

2) Change the pixel format of your Activity window to RGBA_8888 (that is, in onCreate add this line "getWindow (). SetFormat (PixelFormat.RGBA_8888)"). On Android 2.2 and below, the default pixel format is 16 bits (565).

I tried both of them and they fix the grouping effect in my images, however now I am even more confused about what Android does.

On the one hand, if I leave my PNG in a folder with the ability to draw, it will be "optimized", which will lead to the effect of stripes in the image. This magic disappears when I change the pixel format to 32-bit. If the image were “optimized,” I would expect the strip to remain.

On the other hand, if I moved PNG to an unprocessed folder, it will retain a good gradient and display fine even if the pixel format is presumably 16-bit.

If anyone knows what is going on, I would appreciate it.

Thanks,

Dan

+6
android png
source share
1 answer

I find this pretty simple:

You should think about the pixel format of your activity (RGBA_8888) as a DEFAULT optimization for your bitmap images.

If it is not installed, then to 2.2, by default it compresses your bitmap to RGB_565.

But if you have to programmatically create a bitmap and set it to RGBA_8888, then it will be used as such by the application.

The same thing applies when you put a bitmap in a raw folder: even if the PixelFormat parameter is set to RGB_565 by default, the action will use it as it is, without "optimization".

When you put a bitmap in a raw folder, it will not be compressed and used at all, even if the default PixelFormat is still RGB_565.

+8
source share

All Articles