mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-06-05 21:59:19 +02:00
try scaling down the panorama image, if it keeps running out of memory
This commit is contained in:
@@ -129,8 +129,20 @@ open class PanoramaActivity : SimpleActivity() {
|
|||||||
setupButtonMargins()
|
setupButtonMargins()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getBitmapToLoad(path: String): Bitmap {
|
private fun getBitmapToLoad(path: String): Bitmap? {
|
||||||
val bitmap = BitmapFactory.decodeFile(path)
|
val options = BitmapFactory.Options()
|
||||||
|
options.inSampleSize = 1
|
||||||
|
var bitmap: Bitmap? = null
|
||||||
|
|
||||||
|
for (i in 0..10) {
|
||||||
|
try {
|
||||||
|
bitmap = BitmapFactory.decodeFile(path, options)
|
||||||
|
break
|
||||||
|
} catch (e: OutOfMemoryError) {
|
||||||
|
options.inSampleSize *= 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return bitmap
|
return bitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user