Skip to content

Commit

Permalink
Merge pull request #56 from sderr/fix_recycle_warning
Browse files Browse the repository at this point in the history
BitmapCalculator: fix use of a recycled bitmap
  • Loading branch information
skydoves authored May 8, 2024
2 parents 775f779 + 94fcc51 commit d5c4d45
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ internal object BitmapCalculator {
* corresponding dimension of the target size.
*/
internal fun scaleBitmap(bitmap: Bitmap, targetSize: IntSize): Bitmap {
return Bitmap.createScaledBitmap(
bitmap,
targetSize.width,
targetSize.height,
false,
)
val sameSize = (targetSize.height == bitmap.height && targetSize.width == bitmap.width)
return if (sameSize) {
bitmap.copy(bitmap.config, bitmap.isMutable)
} else {
Bitmap.createScaledBitmap(
bitmap,
targetSize.width,
targetSize.height,
false,
)
}
}

/**
Expand Down

0 comments on commit d5c4d45

Please sign in to comment.