保存PNG Drawable Android [英] Saving PNG Drawable Android

查看:194
本文介绍了保存PNG Drawable Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用Bitmap.compress()保存图像,但是我真的想将图像保存为具有Alpha透明性的PNG,而使用Bitmap只会扼杀我的工作.我可以将其另存为不透明的PNG,但不能另存为透明的PNG文件.

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.

有什么办法吗?

谢谢.

推荐答案

尝试一下.我还没有测试过,但是应该可以.

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();

这篇关于保存PNG Drawable Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆