Limit picture upscale factor
Change-Id: I11ea154db505d352ba19d0dbba57c915e3c1d458
This commit is contained in:
parent
4f46f470d6
commit
27cedd62d1
|
@ -316,10 +316,20 @@ class ImageContentRenderer @Inject constructor(private val localFilesHelper: Loc
|
||||||
?: data.url?.takeIf { localFilesHelper.isLocalFile(data.url) && data.allowNonMxcUrls })
|
?: data.url?.takeIf { localFilesHelper.isLocalFile(data.url) && data.allowNonMxcUrls })
|
||||||
|
|
||||||
private fun processSize(data: Data, mode: Mode): Size {
|
private fun processSize(data: Data, mode: Mode): Size {
|
||||||
val maxImageWidth = data.maxWidth
|
var maxImageWidth = data.maxWidth
|
||||||
val maxImageHeight = data.maxHeight
|
var maxImageHeight = data.maxHeight
|
||||||
val width = data.width ?: maxImageWidth
|
val width = data.width ?: maxImageWidth
|
||||||
val height = data.height ?: maxImageHeight
|
val height = data.height ?: maxImageHeight
|
||||||
|
|
||||||
|
// Avoid excessive upscaling
|
||||||
|
val maxUpscale = dimensionConverter.dpToPx(4)
|
||||||
|
if (width in 1 until maxImageWidth) {
|
||||||
|
maxImageWidth = min(maxImageWidth, width*maxUpscale)
|
||||||
|
}
|
||||||
|
if (height in 1 until maxImageHeight) {
|
||||||
|
maxImageHeight = min(maxImageHeight, height*maxUpscale)
|
||||||
|
}
|
||||||
|
|
||||||
var finalWidth = -1
|
var finalWidth = -1
|
||||||
var finalHeight = -1
|
var finalHeight = -1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue