Skip to content

Why is the decoding format based on external input rather than the source material itself? #2845

@lyz1005

Description

@lyz1005

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions