Last active
August 29, 2015 14:21
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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