You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Okay I found out my issue, I needed to convert the Bytes to UBytes:
val r = data[idxStart].toUByte().toInt()
val g = data[idxStart + 1].toUByte().toInt()
val b = data[idxStart + 2].toUByte().toInt()
I found this out by using the debugger and finding out that all the numbers were negative for some reason. Realized it was because of signed Byte limits.
Turns out I didn't even need to do all those transformations, this works as well:
override fun getInt(x: Int, y: Int): Int {
val idxStart = (x * 3) + (y * width * 3)
val r = data[idxStart].toUByte().toInt()
val g = data[idxStart + 1].toUByte().toInt()
val b = data[idxStart + 2].toUByte().toInt()
return (r shl 0) or (g shl 8) or (b shl 16) or (0xFF shl 24)
}
The image looks all wrong:
Can you please take a look at my implementation and see if I'm missing anything?
For context: The webcam image is in terms of sRGB:
https://github.com/Kietyo/webcam-capture-kotlin/blob/master/src/main/kotlin/com/github/sarxos/webcam/ds/buildin/WebcamDefaultDevice.kt#L394
Resources I followed for my implementation:
The text was updated successfully, but these errors were encountered: