Skip to content

Instantly share code, notes, and snippets.

@Jayin
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save Jayin/791fc78e766f1a1d5d8b to your computer and use it in GitHub Desktop.

Select an option

Save Jayin/791fc78e766f1a1d5d8b to your computer and use it in GitHub Desktop.
【Android】save bitmap to localtion. From http://stackoverflow.com/questions/649154/save-bitmap-to-location
// get bitmap from ImageView
Bitmap bmp = ((BitmapDrawable)image.getDrawable()).getBitmap();
FileOutputStream out = null;
try {
out = new FileOutputStream(filename);
bmp.compress(Bitmap.CompressFormat.PNG, 100, out); // bmp is your Bitmap instance
// PNG is a lossless format, the compression factor (100) is ignored
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment