Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个mysql数据库,其中有一个来自java的名为“color”的字符串字段,我保留了这个值:
// (2=color field) pst.setString (2, objeto.getBackground (). getRGB ())
然后我这样读:
objeto.setBackground (Color.decode (rs.getString ("color")))
mysql或php中有什么函数可以读取颜色吗?
你到底想要什么?
将 int 转换为 #RRGGBB 格式的颜色?
sprintf('#%06X', $color);
或获取 R、G、B 值?
$r = ($color >> 16) & 0xFF; $g = ($color >> 8) & 0xFF; $b = ($color >> 0) & 0xFF;
或从 rgb 值创建一个 int
$color = ($r & 0xFF) << 16 | ($g & 0xFF) << 8 | $b & 0xFF