Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Fix NPE while making the screenshot bitmap mutable #1005

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public static void startCalibration(@NonNull Context context,
sCalibrationImage = bitmap;
} else {
// Make a mutable copy of the bitmap so we can draw on it with a Canvas
sCalibrationImage = bitmap.copy(sCalibrationImage.getConfig() ,true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace this line with this instead:

sCalibrationImage = bitmap.copy(bitmap.getConfig(), true);

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also what I thought originally but I checked the reference and realized getConfig() could actually return NULL.

If the bitmap's internal config is in one of the public formats, return that config, otherwise return null.

Maybe I just make an if there

sCalibrationImage = bitmap.copy(
(bitmap.getConfig() != null) ? bitmap.getConfig() : Bitmap.Config.ARGB_8888 ,true);
}

if (!sCalibrationImage.isMutable()) {
Expand Down