Why is the decoding format based on external input rather than the source material itself?
- Dominant language
- Kotlin
- Stars
- 17.2k
- Forks
- 3.7k
- PR merge metrics
- No merged PRs in 30d
Description
private static BitmapFactory.Options getDecodeOptionsForStream(
EncodedImage encodedImage, Bitmap.Config bitmapConfig, boolean skipDecoding) {
final BitmapFactory.Options options = new BitmapFactory.Options();
// Sample size should ONLY be different than 1 when downsampling is enabled in the pipeline
options.inSampleSize = encodedImage.getSampleSize();
options.inJustDecodeBounds = true;
options.inDither = true;
boolean isHardwareBitmap =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && bitmapConfig == Bitmap.Config.HARDWARE;
if (!isHardwareBitmap) {
options.inPreferredConfig = bitmapConfig;
}
options.inMutable = true;
if (!skipDecoding) {
// fill outWidth and outHeight
BitmapFactory.decodeStream(encodedImage.getInputStream(), null, options);
if (options.outWidth == -1 || options.outHeight == -1) {
throw new IllegalArgumentException();
}
}
if (isHardwareBitmap) {
options.inPreferredConfig = bitmapConfig;
}
options.inJustDecodeBounds = false;
return options;
}
Contributor guide
Assessment
This issue has not been assessed yet.