I have a program which is trying to set values in ImageData represented as a Uint8ClampedArray in a Kotlin program. According to the specification for the set method, I need to pass a Kotlin byte into the array, but Kotlin bytes are signed:
...create context...
//setup pix as a js Uint8ClampedArray
val imgd = context.createImageData(100.0, 100.0)
val pix = imgd.data //pix is now a Uint8ClampedArray
//sets pix[40] to 127
pix[40] = 127
//gives an error - Kotlin bytes are signed, so it cannot be passed as a literal
pix[40] = 200
//also doesn't work, still converts to a signed byte
pix[40] = 200.toByte()
My problem with this is that Javascript will read this as only 127, not 255. How can I set values of this array to be greater than 127? I can't even find a hack-y way to make the JS result read what I want, because ultimately the assignment needs a signed byte which doesn't allow for values greater than 127.