and*_*ing 2 android android-gallery
我正在开发Android中的图像着色.因此,当我点击另一个图像视图(例如保存)时将颜色应用于我的图像后,我必须将该图像保存到图库.
Ses*_*nay 19
从imageView以下位置获取位图:
imageview.buildDrawingCache();
Bitmap bm=imageview.getDrawingCache();
Run Code Online (Sandbox Code Playgroud)
要将其保存在文件中:
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 {
bm.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.flush();
fOut.close();
} catch (Exception e) {
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25641 次 |
| 最近记录: |