Skip to content

Commit

Permalink
Merge pull request #4745 from Bnyro/master
Browse files Browse the repository at this point in the history
fix: unexpected crashes from seekbar preview bitmap parsing
  • Loading branch information
Bnyro authored Sep 10, 2023
2 parents d45a954 + 087a397 commit ceca2a2
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class OnlineTimeFrameReceiver(
/**
* Cut off a new bitmap from the image that contains multiple preview thumbnails
*/
private fun cutBitmapFromPreviewFrame(bitmap: Bitmap, previewFrame: PreviewFrame): Bitmap {
val positionX = previewFrame.positionX * previewFrame.frameWidth
val positionY = previewFrame.positionY * previewFrame.frameHeight
val width = minOf(previewFrame.frameWidth, bitmap.width - positionX)
val height = minOf(previewFrame.frameHeight, bitmap.height - positionY)
private fun cutBitmapFromPreviewFrame(bitmap: Bitmap, previewFrame: PreviewFrame): Bitmap? {
val offsetX = previewFrame.positionX * previewFrame.frameWidth
val offsetY = previewFrame.positionY * previewFrame.frameHeight

return Bitmap.createBitmap(bitmap, positionX, positionY, width, height)
return runCatching {
Bitmap.createBitmap(bitmap, offsetX, offsetY, previewFrame.frameWidth, previewFrame.frameHeight)
}.getOrNull()
}

/**
Expand Down

0 comments on commit ceca2a2

Please sign in to comment.