Merge pull request #4745 from Bnyro/master

fix: unexpected crashes from seekbar preview bitmap parsing
This commit is contained in:
Bnyro 2023-09-10 14:23:59 +02:00 committed by GitHub
commit ceca2a28d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
}
/**