Android图片操作-保存图片到SD卡
2015-08-06 14:38
267 查看
/** * Save Bitmap to a file.保存图片到SD卡。 * * @param bitmap * @param file * @return error message if the saving is failed. null if the saving is * successful. * @throws IOException */ public static void saveBitmapToFile(Bitmap bitmap, String _file) throws IOException { BufferedOutputStream os = null; try { File file = new File(_file); // String _filePath_file.replace(File.separatorChar + // file.getName(), ""); int end = _file.lastIndexOf(File.separator); String _filePath = _file.substring(0, end); File filePath = new File(_filePath); if (!filePath.exists()) { filePath.mkdirs(); } file.createNewFile(); os = new BufferedOutputStream(new FileOutputStream(file)); bitmap.compress(Bitmap.CompressFormat.PNG, 100, os); } finally { if (os != null) { try { os.close(); } catch (IOException e) { Log.e(TAG_ERROR, e.getMessage(), e); } } } }
相关文章推荐
- Android图片操作-生成缩略图
- Android图片操作-合并图片
- Android图片操作-截屏
- Android 命令行常用命令
- Android 版本更新功能的实现
- 辛格尔顿和Android
- HTML5,js与Android native通信
- Android性能优化建议 Performance Tips
- Material Design in Action — 哔哩哔哩动画 Android 客户端
- [Android] animated-rotate简单的转菊花...
- Android ViewGroup和View的传递事件
- android:scaleType属性
- android实时刷新
- Android中Adapter之BaseAdapter使用
- Android控件GridView实现分割线
- Android 连接Mysql进行相关操作——用PHP做中介以及JSON做数据交换
- 【Android应用开发技术:数据存储】章节列表
- Android中的应用——谷歌官方Json分析工具Gson使用
- Android项目如何从本地读取JSON字符串
- Android屏幕适配小技巧sw<n>dp