mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +05:30
fix: unexpected crashes from seekbar preview bitmap parsing
This commit is contained in:
parent
ebe7330c8a
commit
087a39757f
@ -20,13 +20,13 @@ class OnlineTimeFrameReceiver(
|
|||||||
/**
|
/**
|
||||||
* Cut off a new bitmap from the image that contains multiple preview thumbnails
|
* Cut off a new bitmap from the image that contains multiple preview thumbnails
|
||||||
*/
|
*/
|
||||||
private fun cutBitmapFromPreviewFrame(bitmap: Bitmap, previewFrame: PreviewFrame): Bitmap {
|
private fun cutBitmapFromPreviewFrame(bitmap: Bitmap, previewFrame: PreviewFrame): Bitmap? {
|
||||||
val positionX = previewFrame.positionX * previewFrame.frameWidth
|
val offsetX = previewFrame.positionX * previewFrame.frameWidth
|
||||||
val positionY = previewFrame.positionY * previewFrame.frameHeight
|
val offsetY = 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)
|
return runCatching {
|
||||||
|
Bitmap.createBitmap(bitmap, offsetX, offsetY, previewFrame.frameWidth, previewFrame.frameHeight)
|
||||||
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user