赞
踩
/** * 保存bitmap到本地 * * @param bitmap Bitmap */ public static void saveBitmap(Bitmap bitmap,String path) { String savePath; File filePic; if (Environment.getExternalStorageState().equals( Environment.MEDIA_MOUNTED)) { savePath = path; } else { Log.e("tag", "saveBitmap failure : sdcard not mounted"); return; } try { filePic = new File(savePath); if (!filePic.exists()) { filePic.getParentFile().mkdirs(); filePic.createNewFile(); } FileOutputStream fos = new FileOutputStream(filePic); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); } catch (IOException e) { Log.e("tag", "saveBitmap: " + e.getMessage()); return; } Log.i("tag", "saveBitmap success: " + filePic.getAbsolutePath()); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。