fix(core): recycle intermediate bitmap in PhotoProcessor.loadSampled to prevent memory leak
This commit is contained in:
parent
7bf16dfe5a
commit
1b2fcfe248
@ -37,7 +37,12 @@ object PhotoProcessor {
|
|||||||
val bitmap = BitmapFactory.decodeFile(path, options)
|
val bitmap = BitmapFactory.decodeFile(path, options)
|
||||||
?: error("无法加载图片: $path")
|
?: error("无法加载图片: $path")
|
||||||
val rotation = readExifRotation(path)
|
val rotation = readExifRotation(path)
|
||||||
return if (rotation == 0) bitmap else rotate(bitmap, rotation)
|
if (rotation == 0) return bitmap
|
||||||
|
val rotated = rotate(bitmap, rotation)
|
||||||
|
if (rotated != bitmap && !bitmap.isRecycled) {
|
||||||
|
bitmap.recycle()
|
||||||
|
}
|
||||||
|
return rotated
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user