Skip to content Skip to sidebar Skip to footer

Saving Png Drawable Android

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

Solution 1:

Had the same issue. Just call bitmap.setHasAlpha(true); before you call compress.

Solution 2:

Try this out. I haven't tested it but it should work.

Bitmapbitmap= Bitmap.createBitmap(width, height, Config.ARGB_8888);
OutputStreamstream=newFileOutputStream("/sdcard/test.png");
bitmap.compress(CompressFormat.PNG, 100, stream);
stream.close();

Post a Comment for "Saving Png Drawable Android"