@@ -7,6 +7,8 @@ import org.json.JSONObject
7
7
import java.io.File
8
8
import java.util.*
9
9
10
+ private val options = BitmapFactory .Options ()
11
+
10
12
/* *
11
13
* Created by PonyCui_Home on 16/6/18.
12
14
*/
@@ -58,14 +60,15 @@ class SVGAVideoEntity {
58
60
private fun resetImages (obj : JSONObject ) {
59
61
obj.optJSONObject(" images" )?.let { imgObjects ->
60
62
imgObjects.keys().forEach { imageKey ->
63
+ options.inPreferredConfig = Bitmap .Config .RGB_565
61
64
var filePath = cacheDir.absolutePath + " /" + imgObjects[imageKey]
62
- var bitmap = if (File (filePath).exists()) BitmapFactory .decodeFile(filePath) else null
65
+ var bitmap = if (File (filePath).exists()) BitmapFactory .decodeFile(filePath, options ) else null
63
66
if (bitmap != null ) {
64
67
images.put(imageKey, bitmap)
65
68
}
66
69
else {
67
70
(cacheDir.absolutePath + " /" + imageKey + " .png" )?.takeIf { File (it).exists() }?.let { it
68
- BitmapFactory .decodeFile(it)?.let {
71
+ BitmapFactory .decodeFile(it, options )?.let {
69
72
images.put(imageKey, it)
70
73
}
71
74
}
@@ -77,20 +80,21 @@ class SVGAVideoEntity {
77
80
private fun resetImages (obj : MovieEntity ) {
78
81
obj.images?.entries?.forEach {
79
82
val imageKey = it.key
80
- val bitmap = BitmapFactory .decodeByteArray(it.value.toByteArray(), 0 , it.value.size())
83
+ options.inPreferredConfig = Bitmap .Config .RGB_565
84
+ val bitmap = BitmapFactory .decodeByteArray(it.value.toByteArray(), 0 , it.value.size(), options)
81
85
if (bitmap != null ) {
82
86
images.put(imageKey, bitmap)
83
87
}
84
88
else {
85
89
it.value.utf8()?.let {
86
90
var filePath = cacheDir.absolutePath + " /" + it
87
- var bitmap = if (File (filePath).exists()) BitmapFactory .decodeFile(filePath) else null
91
+ var bitmap = if (File (filePath).exists()) BitmapFactory .decodeFile(filePath, options ) else null
88
92
if (bitmap != null ) {
89
93
images.put(imageKey, bitmap)
90
94
}
91
95
else {
92
96
(cacheDir.absolutePath + " /" + imageKey + " .png" )?.takeIf { File (it).exists() }?.let { it
93
- BitmapFactory .decodeFile(it)?.let {
97
+ BitmapFactory .decodeFile(it, options )?.let {
94
98
images.put(imageKey, it)
95
99
}
96
100
}
0 commit comments