Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BitmapLoadTask the inSampleSize always 0 ? #727

Closed
zdsagittarius opened this issue Nov 30, 2020 · 2 comments · May be fixed by #809
Closed

BitmapLoadTask the inSampleSize always 0 ? #727

zdsagittarius opened this issue Nov 30, 2020 · 2 comments · May be fixed by #809

Comments

@zdsagittarius
Copy link

BitmapLoadTask File loadFile

final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
options.inSampleSize = BitmapLoadUtils.calculateInSampleSize(options, mRequiredWidth, mRequiredHeight);
options.inJustDecodeBounds = false;

@wj576038874
Copy link

wj576038874 commented May 18, 2021

This is a bug, you need to pass in the options to load and then output the width and height to the options, so that inSampleSize can be calculated correctly:

final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
try {
BitmapFactory.decodeStream(mContext.getContentResolver().openInputStream(mInputUri) ,null, options);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
options.inSampleSize = BitmapLoadUtils.calculateInSampleSize(options, mRequiredWidth, mRequiredHeight);
options.inJustDecodeBounds = false;

@dmitriy1morozov
Copy link
Contributor

To be fixed with #809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants