Skip to content

Commit

Permalink
Merge pull request #4717 from Bnyro/master
Browse files Browse the repository at this point in the history
fix: crash when scrubbing timebar on certain videos
  • Loading branch information
Bnyro authored Sep 8, 2023
2 parents 9c78391 + 50eefcb commit 1d7fce9
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ class OnlineTimeFrameReceiver(
* Cut off a new bitmap from the image that contains multiple preview thumbnails
*/
private fun cutBitmapFromPreviewFrame(bitmap: Bitmap, previewFrame: PreviewFrame): Bitmap {
return Bitmap.createBitmap(
bitmap,
previewFrame.positionX * previewFrame.frameWidth,
previewFrame.positionY * previewFrame.frameHeight,
previewFrame.frameWidth,
previewFrame.frameHeight
)
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)

return Bitmap.createBitmap(bitmap, positionX, positionY, width, height)
}

/**
Expand Down

0 comments on commit 1d7fce9

Please sign in to comment.