Code example for BufferedInputStream

Methods: decodeStreamclosemarkreset

0
	    try { 
	        //Decode image size 
	        BitmapFactory.Options o = new BitmapFactory.Options();
	        o.inJustDecodeBounds = true;
 
	        BufferedInputStream bis = new BufferedInputStream(is);
	        bis.mark(Integer.MAX_VALUE);
	         
	        BitmapFactory.decodeStream(bis, null, o);
	        bis.reset();
	         
	        int scale = 1;
	        if (o.outHeight > desiredHeight || o.outWidth > desiredWidth) {
	            scale = (int)Math.pow(2, (int) Math.round(Math.log(Math.max(desiredHeight, desiredWidth) / (double) Math.max(o.outHeight, o.outWidth)) / Math.log(0.5)));
	        } 
 
	        //Decode with inSampleSize 
	        BitmapFactory.Options o2 = new BitmapFactory.Options();
	        o2.inSampleSize = scale;
	        o2.inDither = true;
	        o2.inPurgeable = true;
	         
	        b = BitmapFactory.decodeStream(bis, null, o2);
	        bis.close();
	        is.close();
	    } catch (IOException e) {
	    	e.printStackTrace();
	    } 
	    return b;
Contextual code suggestions in your IDE  Get Codota for Java