2017-03-06 19:06
浏览 221


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.


Could you help me convert these values to either HEX or RGB in either Oracle or PHP which 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

Additional Edit

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.

图片转代码服务由CSDN问答提供 功能建议

我从未见过像 -1 -16777216 <的颜色代码 / code>, -256 等等。所以我目前的问题是:

我们有第三方软件,您可以将值颜色编码为 如下图所示。

现在我正在创建一个显示这些值的PHP报告但是 我还想使用与软件中定义的颜色相同的颜色显示它们。 我能够从数据库中查找值,但我很困惑,因为值是我不熟悉的格式或符号。

< / a>

你能帮助我将这些值转换为Oracle或PHP中的HEX或RGB,这是我习惯的(我会将它用于报告的CSS) 。



-1 = White

-12582784 = Purple \ n

-65408 = Pink

-16777216 = Black

-256 =黄色


因此看起来16777216是一个完美的立方体编号。 它的立方根是256(在RGB上,每个原色可以用0-255的数字表示)。 到目前为止,这是我能看到的唯一关系。 我仍然不知道如何将其转换为HEX或RGB。

我做了一些研究,虽然效果不佳。 但我会把它包括在内,所以我看起来并没有尝试 - 如果你对它不感兴趣,那就忽略它:

16777216 - 我开始搜索实际代码 -16777216 但是没有返回任何东西,所以我删除了负号。

关于16777216的事实 - 该页面显示了一些公式,但我没有看到任何转换为​​HEX或RGB。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • dongpo5239 2017-03-06 20:19

    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. :)

    解决 无用
    打赏 举报

相关推荐 更多相似问题