1

The app is compiled with following version config:

compileSdkVersion 23

buildToolsVersion "23.0.2"

minSdkVersion 18

targetSdkVersion 23

The app has a bitmap which contains transparent regions. I'm using WEBP format to save the bitmap to file.

Bitmap config is ARGB_8888

bitmap.hasAlpha() returns true

Tested the particular pixels in the Bitmap before saving and verified that some regions are transparent.

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

The above code works correctly when tested with API v22, v23. transparency details are stored in the generated file.

The same code, when tested with API v18, v19, v21 doesn't save the alpha channel to file. The transparent regions are black.

All API versions work correctly while decoding the WEBP file.

I'm about to bundle the libwebp with the app, but seems like all documentation suggests that this should be supported. Has anyone faced a similar issue?

UPDATE: I implemented the encoding using libwebp native library. Still curious if anyone else came across the same issue

Gaurav Gupta
  • 446
  • 6
  • 12
  • Same issue, without solution yet: http://stackoverflow.com/questions/39428789/bitmap-compressformat-webp-on-android-api-19-alpha-channel-becomes-black – ryuujin Sep 10 '16 at 18:24

1 Answers1

0

I think its a bug in Android. Documentation suggests that alpha channel for webp is supported starting 4.2.1, but thats probably just the decoding for viewing in Chrome browser & Photo Gallery.

I solved the problem by integrating the libwebp native library and making the call over JNI to encode the Bitmap. Works perfectly!

Gaurav Gupta
  • 446
  • 6
  • 12