speedup blurhash decoding by using a intermediate int array (#1835)
This commit is contained in:
parent
836b7f3f76
commit
5246ab7d72
1 changed files with 3 additions and 3 deletions
|
@ -87,7 +87,7 @@ object BlurHashDecoder {
|
||||||
numCompX: Int, numCompY: Int,
|
numCompX: Int, numCompY: Int,
|
||||||
colors: Array<FloatArray>
|
colors: Array<FloatArray>
|
||||||
): Bitmap {
|
): Bitmap {
|
||||||
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
val imageArray = IntArray(width * height)
|
||||||
for (y in 0 until height) {
|
for (y in 0 until height) {
|
||||||
for (x in 0 until width) {
|
for (x in 0 until width) {
|
||||||
var r = 0f
|
var r = 0f
|
||||||
|
@ -102,10 +102,10 @@ object BlurHashDecoder {
|
||||||
b += color[2] * basis
|
b += color[2] * basis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bitmap.setPixel(x, y, Color.rgb(linearToSrgb(r), linearToSrgb(g), linearToSrgb(b)))
|
imageArray[x + width * y] = Color.rgb(linearToSrgb(r), linearToSrgb(g), linearToSrgb(b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bitmap
|
return Bitmap.createBitmap(imageArray, width, height, Bitmap.Config.ARGB_8888)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun linearToSrgb(value: Float): Int {
|
private fun linearToSrgb(value: Float): Int {
|
||||||
|
|
Loading…
Reference in a new issue