在android中保存为png图像

发布于 2024-10-10 08:55:57 字数 129 浏览 0 评论 0原文

我正在开发绘画应用程序,并将我的绘图保存为 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温折酒 2024-10-17 08:55:57

模拟器工作正常。您使用哪段代码将位图存储为 png ?

以下在模拟器中运行良好:

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

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文