Skip to content

Commit

Permalink
Create mutable bitmap copy if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isira-Seneviratne committed Aug 6, 2022
1 parent 40c7afd commit 34e1e94
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/src/main/java/org/schabi/newpipe/util/PicassoHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,20 @@ public Bitmap transform(final Bitmap source) {
.getDimension(R.dimen.player_notification_thumbnail_width),
source.getWidth());

final Bitmap result = BitmapCompat.createScaledBitmap(
Bitmap result = BitmapCompat.createScaledBitmap(
source,
(int) notificationThumbnailWidth,
(int) (source.getHeight()
/ (source.getWidth() / notificationThumbnailWidth)),
null,
true);

if (result != source) {
source.recycle();
// create a new mutable bitmap to prevent strange crashes on some devices
// (see #4638)
if (!result.isMutable()) {
result = result.copy(result.getConfig(), true);
}
source.recycle();
return result;
}

Expand Down

0 comments on commit 34e1e94

Please sign in to comment.