對InputStream進行壓縮,即con.getInputStream()code
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options(); bitmapOptions.inSampleSize = 10; //壓縮爲原來的10分之一 bitmap = BitmapFactory.decodeStream(con.getInputStream(), null , bitmapOptions);
對Bitmap壓縮orm
bitmap.compress(Bitmap.CompressFormat.JPEG, 10, fos); //10表明壓縮90%