try scaling down the panorama image, if it keeps running out of memory
This commit is contained in:
parent
c32b332804
commit
40de93100c
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue