Best way to load image from iOS CMSampleBuffer or ByteArray?
Closed this issue · 1 comments
luca992 commented
I've tried going through the docs. But, I'm a bit confused. What would be the best way to load an image from ios's CMSampleBuffer or a CMSampleBuffer dumped into a ByteArray?
luca992 commented
Never mind, figured it out. I think it should be something like this:
fun NSData.toIntArray(): IntArray = IntArray(this@toIntArray.length.toInt() / 4 ).apply {
usePinned {
memcpy(it.addressOf(0), this@toIntArray.bytes, this@toIntArray.length)
}
}
suspend fun displayImage(w: Int, h: Int, imageData: NSData){
val image = NativeImage(w, h, RgbaArray(imageData.toIntArray()))
image.toNonNativeBmp().showImageAndWait() // display not implemented
}