如何将油漆以及背景保存到 sdcars 中

发布于 2025-01-07 15:50:18 字数 614 浏览 3 评论 0原文

我的 Android 应用程序应该将绘画和背景图像保存在我设备的 SD 卡上。我在我的视图类中使用下面的方法,但由于某种原因,SD 卡只保存油漆。我不明白为什么背景图像没有保存。

File myDir=new File("/sdcard/saved_images");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-"+ n +".jpg";
File file = new File (myDir, fname);
if (file.exists ()) file.delete (); 
try {
    FileOutputStream out = new FileOutputStream(file);
    mBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
    out.flush();
    out.close();
} catch (Exception e) {
    e.printStackTrace();
}   

这是我试图保存背景的地方,但它不起作用。任何想法将不胜感激。

My Android application is supposed to save paints and a background image on my device's SD Card. I am using the method below inside my view class, but for some reason the SD Card is only saving the paints. I can't figure out why the background image isn't saving.

File myDir=new File("/sdcard/saved_images");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-"+ n +".jpg";
File file = new File (myDir, fname);
if (file.exists ()) file.delete (); 
try {
    FileOutputStream out = new FileOutputStream(file);
    mBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
    out.flush();
    out.close();
} catch (Exception e) {
    e.printStackTrace();
}   

This is where I'm attempting to save the background, but it isn't working. Any ideas would be greatly appreciated.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文