问题
I know how to save an image with Bitmap.compress(), but I really want to save the image as a PNG with its alpha-transparency, and using Bitmap just kills my efforts. I can save it as a opaque PNG, but not as a transparent PNG file.
Is there any approach to this?
Thank you.
回答1:
Try this out. I haven't tested it but it should work.
Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
OutputStream stream = new FileOutputStream("/sdcard/test.png");
bitmap.compress(CompressFormat.PNG, 100, stream);
stream.close();
回答2:
Had the same issue. Just call bitmap.setHasAlpha(true);
before you call compress.
来源:https://stackoverflow.com/questions/11518910/saving-png-drawable-android