android, desktop: fix crash when window is small in chat view (#4819)

This commit is contained in:
Stanislav Dmitrenko
2024-09-03 13:37:04 +00:00
committed by GitHub
parent 2089fd8539
commit 9cba96082d
@@ -356,7 +356,8 @@ sealed class WallpaperType {
private fun drawToBitmap(image: ImageBitmap, imageScale: Float, tint: Color, size: Size, density: Float, layoutDirection: LayoutDirection): ImageBitmap {
val quality = if (appPlatform.isAndroid) FilterQuality.High else FilterQuality.Low
val drawScope = CanvasDrawScope()
val bitmap = ImageBitmap(size.width.toInt(), size.height.toInt())
// Don't allow to make zero size because it crashes the app when reducing a size of a window on desktop
val bitmap = ImageBitmap(size.width.toInt().coerceAtLeast(1), size.height.toInt().coerceAtLeast(1))
val canvas = Canvas(bitmap)
drawScope.draw(
density = Density(density),