PB将LONG类型的color值转换为RGB值

文章介绍了如何在PB(PowerBuilder)环境中将使用RGB函数表示的颜色值分解回其红色、绿色和蓝色分量。通过提供的RGB公式65536*Blue+256*Green+Red,可以计算出每个分量的整数值。示例代码展示了如何从一个long颜色值解码出对应的red、green和blue值。
摘要由CSDN通过智能技术生成

我们知道在PB中使用rgb函数使用rgb颜色,但是怎么转换回来呢

st_1.backcolor = rgb(209,92,445)

参考帮助说明

Syntax
RGB ( red , green , blue )
Argument
Description
        red
        The integer value of the red component of the desired color
        green
        The integer value of the green component of the desired color
        blue
        The integer value of the blue component of the desired color
Return value
        Long. Returns the long that represents the color created by combining the values specified in red, green, and blue. If an error occurs, RGB returns -1. If any argument's value is null , RGB returns null .
Usage
The formula for combining the colors is:
        65536 * Blue + 256 * Green + Red
Use RGB to obtain the long value required to set the color for text and drawing objects. You can also set an object's color to the long value that represents the color. The RGB function provides an easy way to calculate that value
根据公式 65536 * Blue + 256 * Green + Red 生成
long ll_color
int li_r,li_g,li_b

//pb颜色值
li_color = long(sle_1.text)

//65536 * Blue+ 256 * Green+ Red
li_b = ll_color\ 65536
li_g = (ll_color - li_b * 65536) \ 256
li_r = ll_color - li_b * 65536 - li_g * 256
em_r.text = string(li_r)
em_g.text = string(li_g)
em_b.text = string(li_b)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值