Code example for BufferedInputStream

Methods: decodeStream, mark, reset

0
	} 
	 
	public static Bitmap decodeSampleBitmapFromInputStream(InputStream is, 
			int reqWidth, 
			boolean faster_mode, Context context) {
		final BufferedInputStream ins = new BufferedInputStream(is, 32 * 1024);
		try { 
			final BitmapFactory.Options options = new BitmapFactory.Options();
		    options.inJustDecodeBounds = true;
		    options.inPurgeable = true;
		    ins.mark(32 * 1024);
		    BitmapFactory.decodeStream(ins, null, options);
		    ins.reset();
		    options.inSampleSize = calculateInSampleSizeByWidth(options, reqWidth);
		    options.inJustDecodeBounds = false;
		    options.inPreferredConfig = Bitmap.Config.RGB_565;
//		    options.inDensity = context.getResources().getDisplayMetrics().densityDpi; 
//		    options.inTargetDensity = context.getResources().getDisplayMetrics().densityDpi; 
//		    options.inDither = true; 
//		    options.inScaled = true; 
		    return BitmapFactory.decodeStream(ins, null, options);
		} catch (Exception e) {
			e.printStackTrace();
		} 
		return null; 
	}