eygraber
12/07/2022, 1:19 AMinternal actual fun ByteArray.putBytesInto(array: IntArray, offset: Int, length: Int): Unit =
TODO("implement js ByteArray.putBytesInto()")
The jvm implementation is:
internal actual fun ByteArray.putBytesInto(array: IntArray, offset: Int, length: Int) {
ByteBuffer.wrap(this)
.order(ByteOrder.LITTLE_ENDIAN) // to return ARGB
.asIntBuffer()
.get(array, offset, length)
}
Would the following be a correct implementation (even if not optimal):
internal actual fun ByteArray.putBytesInto(array: IntArray, offset: Int, length: Int) {
val byteBuffer = Uint8Array(this.toTypedArray()).buffer
val intArray = Int32Array(byteBuffer, offset, length)
for(i in 0 until intArray.length) {
array[i] = intArray[i]
}
}
turansky
12/07/2022, 8:48 AMByteArray
is Uint8Array
aliaseygraber
12/07/2022, 3:27 PMbuffer
directly