Skip to content

Commit

Permalink
Merge branch 'main' into feature/blurhash-android
Browse files Browse the repository at this point in the history
  • Loading branch information
gtokman authored Sep 13, 2024
2 parents fb45bf9 + 14e0422 commit 86a23fd
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,17 @@ import com.facebook.react.uimanager.events.RCTEventEmitter
val intArray = IntArray(byteArray.size)
for (i in byteArray.indices) {
intArray[i] = byteArray[i].toInt() and 0xFF
val intArray = IntArray(thumbHash.width * thumbHash.height)
for (i in intArray.indices) {
val r = thumbHash.rgba[i * 4].toInt() and 0xFF
val g = thumbHash.rgba[i * 4 + 1].toInt() and 0xFF
val b = thumbHash.rgba[i * 4 + 2].toInt() and 0xFF
val a = thumbHash.rgba[i * 4 + 3].toInt() and 0xFF
intArray[i] =
((a and 0xff) shl 24) or ((r and 0xff) shl 16) or ((g and 0xff) shl 8) or (b and 0xff)
}
return intArray
val bitmap = Bitmap.createBitmap(intArray, thumbHash.width, thumbHash.height, Bitmap.Config.ARGB_8888)
return BitmapDrawable(view.context.resources, bitmap)
}

companion object {
Expand Down

0 comments on commit 86a23fd

Please sign in to comment.