android:保存bitmap

直接看代码吧:

/**
	 * 保存图片
	 * @param mSignBitmap
	 * @param _path 图片保存路径
	 * @return
	 */
	public static boolean createFile(Bitmap mSignBitmap,String _path) {
		ByteArrayOutputStream baos = null;
		try {
			baos = new ByteArrayOutputStream();
			mSignBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
			byte[] photoBytes = baos.toByteArray();
			if (photoBytes != null) {
				new FileOutputStream(new File(_path)).write(photoBytes);
			}
			return true;
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (baos != null)
					baos.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return false;
	}

 

你可能感兴趣的:(android保存图片)