在android中保存为png图像

Saving as a png image in android(在android中保存为png图像)
本文介绍了在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图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)