val bb = terrain!![posRed + 1] and 0xff.toByte()
val gg = terrain[posRed + 2] and 0xff.toByte()
val rr = terrain[posRed + 3] and 0xff.toByte()
g.color = Color(rr.toInt(), gg.toInt(), bb.toInt())
i
ilya.gorbunov
09/10/2018, 11:56 PM
Here you have
bb
,
gg
and
rr
still having
Byte
type and that type is signed: it ranges from -128 to 127. The negative values are outside of the color component range when you convert them to int.
h
Hullaballoonatic
09/10/2018, 11:57 PM
so what is your suggestion? convert the byte to Int instead of the Int to Byte?
i
ilya.gorbunov
09/10/2018, 11:57 PM
try
Copy code
val rr = terrain[posRed + 1].toInt() and 0xFF
...
g.color = Color(rr, gg, bb)