本文介绍了如何使用 imageview onclick 保存位图图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发 android 中的图像着色.因此,当我单击另一个图像视图(如保存)时,将颜色应用于我的图像后,我必须将该图像保存到图库.
Am developing a coloring of images in android. So after applying colors to my image when i click another imageview like save, then i have to save that image to gallery.
推荐答案从imageView获取位图:
imageview.buildDrawingCache(); Bitmap bm=imageview.getDrawingCache();要将其保存在文件中:
OutputStream fOut = null; Uri outputFileUri; try { File root = new File(Environment.getExternalStorageDirectory() + File.separator + "folder_name" + File.separator); root.mkdirs(); File sdImageMainDirectory = new File(root, "myPicName.jpg"); outputFileUri = Uri.fromFile(sdImageMainDirectory); fOut = new FileOutputStream(sdImageMainDirectory); } catch (Exception e) { Toast.makeText(this, "Error occured. Please try again later.", Toast.LENGTH_SHORT).show(); } try { bmpress(Bitmap.CompressFormat.PNG, 100, fOut); fOut.flush(); fOut.close(); } catch (Exception e) { }更多推荐
如何使用 imageview onclick 保存位图图像
发布评论