1. Save the picture file to the SD card
Private InputStream Bitmap2is (Bitmap BM) {Bytearrayoutputstream BAOs = new Bytearrayoutputstream (); Bm.compress ( Bitmap.CompressFormat.PNG, BAOs) InputStream SBS = new Bytearrayinputstream (Baos.tobytearray ()); return SBS;} public void Onclick_saveimagetosdcard (view view) {try {fileoutputstream fos = new FileOutputStream (album_path+ "/ Qrcode.png ");//InputStream is = Getresources (). Getassets (). Open (" Image.jpg "), InputStream is = bitmap2is (bit); byte[] BUF = new Byte[4096];int count = 0;while ((count = Is.read (buf)) >= 0) {fos.write (buf, 0, count);} Fos.close (); Is.close ();/* * byte[] buffer = new byte[8192]; int count = 0; while ((count = * Is.read (buffer)) >= 0) {fos.write (buffer,0,count);} fos.close (); * Is.close (); */toast.maketext (This, "write success! ", Toast.length_long). Show ();} catch (Exception e) {//Todo:handle Exceptiontoast.maketext (this, E.getmessage (), Toast.length_long). Show ();}}
Several common functions of Android