在android中保存为png图像 [英] Saving as a png image in android

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

问题描述

我正在开发绘画应用程序并将我的绘图保存为 png 图像.对于绘图,我使用了用位图创建的画布.它可以工作,但图像已损坏.谁能帮我.我没有用真机检查,而是在模拟器上检查.是模拟器的问题.我认为它的处理能力很小.我对吗?谢谢.

I am developing paint app and i save my drawing as png image. For drawing i used canvas that created with a bitmap. it works but image was corrupted. Can any one help me. I didn't check it with a real phone but on the emulator. Is that problem with emulator. I think it has very small processing ability. Am i right? Thank you.

推荐答案

模拟器运行良好.您使用哪段代码将位图存储为 png?

The emulator works fine. What piece of code did you use to store the bitmap as png?

以下在模拟器中可以正常工作:

The following works fine in the emulator:

Bitmap bitmap = createYourBitmap();
OutputStream stream = new FileOutputStream("/sdcard/test.png");
/* Write bitmap to file using JPEG or PNG and 80% quality hint for JPEG. */
bitmap.compress(CompressFormat.PNG, 80, stream);
stream.close();

这篇关于在android中保存为png图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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