Domanda

I know there are different types of png compression formats (using color palette for example). Is it possible to (programatically) determine the type I want to use when compressing a Bitmap in Android?

If the answer is no, can anyone suggest a method for doing so? Thanks

È stato utile?

Soluzione

In Android there's no client API to specify that, because Bitmap.compress() calls a native method which doesn't accept such a parameter.

However you can use libpng (which BTW is what I think Android uses in its native implementation) and it certainly allows the fine-grained control you need.

But I really don't think that saving a bunch of KBytes in a GB-sized drive is worth this effort.

Altri suggerimenti

You can also use PNGJ, it allows full control over the writing parameters.

Eventually I had to make changes to the Android's skia library, since I didn't want to add any Java code (I need to make png compressions fast). If anyone needs such a solution, I uploaded mine to:
https://github.com/androidcompile/Android_external_skia_pngCompression

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top