image file converted to bitmap object
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));//The length and width of the picture will be reduced to taste the original
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 void Savebitmapfile (Bitmap Bitmap) {
File File=new file ("/mnt/sdcard/pic/01.jpg");//path where the picture will be saved
try {
Bufferedoutputstream BOS = new Bufferedoutputstream (new FileOutputStream (file));
Bitmap.compress (Bitmap.CompressFormat.JPEG, N, BOS);
Bos.flush ();
Bos.close ();
} catch (IOException e) {
E.printstacktrace ();
}
}
Conversion between picture files and bitmap