I've never seen color codes like -1, -16777216, -256, etc. So my current problem is this:
We have a third-party software where you can color-code a value as illustrated in the picture below.

Now I'm creating a PHP report that displays those values but I also want to display them using the same colors as what is defined in the software. I was able to hunt the values down from the database but I'm confused as the values are in a format or notation that I'm not familiar with.

How can I convert these values to either HEX or RGB in either Oracle or PHP? PHP is what I'm used to (I will use it for CSS for the report).
Looking at the database and the colors in the software I could at least match the numbers like so:
-1= White
-12582784= Purple
-65408= Pink
-16777216= Black
-256= Yellow
So it looks like 16777216 is a perfect cube number. Its cube root is 256 (on RGB each primary color can be represented by a number from 0-255). So far that's the only relationship I can see think of. I still don't know how to convert that to HEX or RGB though.
I've done some research although not really fruitful. But I'll include it so I don't look like I didn't make an attempt - if you're not interested in it then just ignore it:
16777216 - I started by searching the actual code -16777216 but that didn't return anything so I removed the negative sign.
Facts about 16777216 - that page shows some formulas but I didn't see any that converts to HEX or RGB.
Your colours are indeed RGB values stored in a slightly twisted way. All you have to do is, take the decimal number away from 16777216 and convert to HEX.
16777216-1 = 16777215 (FFFFFFh = White)
16777216-12582784 = 4194432 (400080h = Purple)
16777216-65408 = 16711808 (FF0080h = Pink)
16777216-16777216 = 0 (000000h = Black)
16777216-256 = 16776960 (FFFF00h = Yellow)
I hope this helps. Apologies for not writing a code, but I am afraid I am not quite there yet in my studies. I promise I will work on it when I get there. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With