@SuppressWarnings("deprecation")
    private static Bitmap.Config getConfig(InputStream is, DecodeFormat format) {
        // Changing configs can cause skewing on 4.1, see issue #128.
        if (format == DecodeFormat.ALWAYS_ARGB_8888 || format == DecodeFormat.PREFER_ARGB_8888
                || Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN) {
            return Bitmap.Config.ARGB_8888;
        }

        boolean hasAlpha = false;
        // We probably only need 25, but this is safer (particularly since the buffer size is > 1024).
        is.mark(1024);
        try {
            hasAlpha = new ImageHeaderParser(is).hasAlpha();
        } catch (IOException e) {
            if (Log.isLoggable(TAG, Log.WARN)) {
                Log.w(TAG, "Cannot determine whether the image has alpha or not from header for format " + format, e);
            }
        } finally {
            try {
                is.reset();
            } catch (IOException e) {
                if (Log.isLoggable(TAG, Log.WARN)) {
                    Log.w(TAG, "Cannot reset the input stream", e);
                }
            }
        }

        return hasAlpha ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565;
    }
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