/** * Returns a Bitmap decoded from the given {@link InputStream} that is rotated to match any EXIF * data present in the stream and that is downsampled according to the given dimensions and any * provided {@link com.bumptech.glide.load.resource.bitmap.DownsampleStrategy} option. * * @see #decode(InputStream, int, int, Options, DecodeCallbacks) */ public Resource<Bitmap> decode(InputStream is, int outWidth, int outHeight, Options options) throws IOException { return decode(is, outWidth, outHeight, options, EMPTY_CALLBACKS); }
@Override public Resource<Bitmap> decode(@NonNull ByteBuffer source, int width, int height, @NonNull Options options) throws IOException { InputStream is = ByteBufferUtil.toStream(source); return downsampler.decode(is, width, height, options); } }
UntrustedCallbacks callbacks = new UntrustedCallbacks(bufferedStream, exceptionStream); try { return downsampler.decode(invalidatingStream, width, height, options, callbacks); } finally { exceptionStream.release();
/** Returns an error string if the test failed, and {@code null} otherwise. */ @Nullable private static String runScaleTest( CompressFormat format, int initialWidth, int initialHeight, int targetWidth, int targetHeight, DownsampleStrategy strategy, int expectedWidth, int expectedHeight) throws IOException { Downsampler downsampler = buildDownsampler(); InputStream is = openBitmapStream(format, initialWidth, initialHeight); Options options = new Options().set(DownsampleStrategy.OPTION, strategy); Bitmap bitmap = downsampler.decode(is, targetWidth, targetHeight, options).get(); try { if (bitmap.getWidth() != expectedWidth || bitmap.getHeight() != expectedHeight) { return "API: " + Build.VERSION.SDK_INT + ", os: " + Build.VERSION.RELEASE + ", format: " + format + ", strategy: " + strategy + " -" + " Initial " + readableDimens(initialWidth, initialHeight) + " Target " + readableDimens(targetWidth, targetHeight) + " Expected " + readableDimens(expectedWidth, expectedHeight) + ", but Received " + readableDimens(bitmap.getWidth(), bitmap.getHeight()); } } finally { bitmap.recycle(); } return null; }
@Override public Resource<Bitmap> decode(InputStream source, int width, int height) { Bitmap bitmap = downsampler.decode(source, bitmapPool, width, height, decodeFormat); return BitmapResource.obtain(bitmap, bitmapPool); }
/** * Returns a Bitmap decoded from the given {@link InputStream} that is rotated to match any EXIF * data present in the stream and that is downsampled according to the given dimensions and any * provided {@link com.bumptech.glide.load.resource.bitmap.DownsampleStrategy} option. * * @see #decode(InputStream, int, int, Options, DecodeCallbacks) */ public Resource<Bitmap> decode(InputStream is, int outWidth, int outHeight, Options options) throws IOException { return decode(is, outWidth, outHeight, options, EMPTY_CALLBACKS); }
@Override public Resource<Bitmap> decode(ByteBuffer source, int width, int height, Options options) throws IOException { InputStream is = ByteBufferUtil.toStream(source); return downsampler.decode(is, width, height, options); } }
UntrustedCallbacks callbacks = new UntrustedCallbacks(bufferedStream, exceptionStream); try { return downsampler.decode(invalidatingStream, width, height, options, callbacks); } finally { exceptionStream.release();