how can I find the color color created with bitmask? For example, what is the color equivalent of this expression?
color = -16777216
CodePudding user response:
That depends entirely on the underlying pixel format. Without knowing that crucially important information it's impossible to answer!
Without knowing the color space and pixelformat being used, you can't answer that.
For the sake of argument lets assume that the pixel format was little endian, RGBA with 8 bits per channel packed into a single 32 bit value with red in the least significant bits and alpha in the most significant ones.
The binary representation of -16777216
in 2s complement would be
b_11111111_00000000_00000000_00000000
or in hexadecimal
h_ff000000
According to the pixelformat we assumed that would be A=100%, R=B=G=0%, i.e. a fully opaque black.
CodePudding user response:
You can easily do this with Integer.toHexString.
val bitmaskColor = -16777216
Log.e("HEX",Integer.toHexString(bitmaskColor)) // ff000000