I suspect two things are at play here.
Firstly JPEG is a lossy format so the number you put in might not be the exact number you get out, a true black is likely to become a gray.
Secondly, why do you get a negative when you start with a positive number? Well this is all down to the way int
and uint
and colours are represented in binary.
In RGB notation black has hex value #ffffff
in ARGB it is #ffffffff
.
0xffffffff
in hex is 4,294,967,295 in decimal.
However an int
is a signed type, meaning it is represented in two's complement representation
If the highest bit in the bit in the number is set then you need to deduct -2,147,483,648; that is, hexadecimal 0x80000000.
So 0xffffffff becomes 2,147,483,647 - 2,147,483,648 = -1.
If your black became a slight gray like #ffeeeeee then its decimal value in two's complement notation would be -2,146,365,166.