String filepath="c:/01.jpg"; Bitmap Bitmap=bitmapfactory.decodefile (FilePath);
If the picture is too large, it may cause the bitmap object to be loaded
Workaround:
String filepath= c:/01.jpg " ; Bitmap Bitmap =bitmapfactory.decodefile (filepath,getbitmapoption (2 )) ; // private Options getbitmapoption (int Insamplesize) { System.GC (); Bitmapfactory.options Options = new Bitmapfactory.options (); options.inpurgeable = true ; Options.insamplesize = insamplesize; return options;}
Bitmap object Save flavor Picture file
Public voidsavebitmapfile (Bitmap Bitmap) {File file=NewFile ("/mnt/sdcard/pic/01.jpg");//the path where the picture will be saved Try{bufferedoutputstream Bos=NewBufferedoutputstream (Newfileoutputstream (file)); Bitmap.compress (Bitmap.CompressFormat.JPEG, -, BOS); Bos.flush (); Bos.close (); } Catch(IOException e) {e.printstacktrace (); }}
Conversion between Android picture files and bitmap