private Bitmap downsampleWithSize(MarkEnforcingInputStream is, RecyclableBufferedInputStream  bufferedStream,
            BitmapFactory.Options options, BitmapPool pool, int inWidth, int inHeight, int sampleSize,
            DecodeFormat decodeFormat) {
        // Prior to KitKat, the inBitmap size must exactly match the size of the bitmap we're decoding.
        Bitmap.Config config = getConfig(is, decodeFormat);
        options.inSampleSize = sampleSize;
        options.inPreferredConfig = config;
        if ((options.inSampleSize == 1 || Build.VERSION_CODES.KITKAT <= Build.VERSION.SDK_INT) && shouldUsePool(is)) {
            int targetWidth = (int) Math.ceil(inWidth / (double) sampleSize);
            int targetHeight = (int) Math.ceil(inHeight / (double) sampleSize);
            // BitmapFactory will clear out the Bitmap before writing to it, so getDirty is safe.
            setInBitmap(options, pool.getDirty(targetWidth, targetHeight, config));
        }
        return decodeStream(is, bufferedStream, options);
    }
Load the image for the given InputStream. If a recycled Bitmap whose dimensions exactly match those of the image
for the given InputStream is available, the operation is much less expensive in terms of memory.

<p>
    Note - this method will throw an exception of a Bitmap with dimensions not matching
    those of the image for the given InputStream is provided.
</p>

@param is An {@link InputStream} to the data for the image.
@param pool A pool of recycled bitmaps.
@param outWidth The width the final image should be close to.
@param outHeight The height the final image should be close to.
@return A new bitmap containing the image from the given InputStream, or recycle if recycle is not null.
core/src/main/java/com/bumptech/glide/load/resource/bitmap/Downsampler.java