Android学习之保存Bitmap到指定目录

/**
	 * 保存图片到指定目录
	 * 
	 * @param bmp
	 * @param filename
	 * @return
	 */
	private boolean saveBitmapTofile(Bitmap bmp, String filename) {
		if (bmp == null || filename == null)
			return false;
		CompressFormat format = Bitmap.CompressFormat.JPEG;
		int quality = 100;
		OutputStream stream = null;
		try {
			stream = new FileOutputStream("/sdcard/myimage/" + filename);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return bmp.compress(format, quality, stream);
	}

posted @ 2017-07-03 14:22  jzdwajue  阅读(201)  评论(0编辑  收藏  举报