private static boolean shouldUsePool(InputStream is) {
        // On KitKat+, any bitmap can be used to decode any other bitmap.
        if (Build.VERSION_CODES.KITKAT <= Build.VERSION.SDK_INT) {
            return true;
        }

        is.mark(1024);
        try {
            final ImageHeaderParser.ImageType type = new ImageHeaderParser(is).getType();
            // cannot reuse bitmaps when decoding images that are not PNG or JPG.
            // look at : https://groups.google.com/forum/#!msg/android-developers/Mp0MFVFi1Fo/e8ZQ9FGdWdEJ
            return TYPES_THAT_USE_POOL.contains(type);
        } catch (IOException e) {
            if (Log.isLoggable(TAG, Log.WARN)) {
                Log.w(TAG, "Cannot determine the image type from header", e);
            }
        } finally {
            try {
                is.reset();
            } catch (IOException e) {
                if (Log.isLoggable(TAG, Log.WARN)) {
                    Log.w(TAG, "Cannot reset the input stream", e);
                }
            }
        }
        return false;
    }
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