COLORREF to RGB
COLORREF to RGB
我正在尝试使用JavaScript转换COLORREF
:
COLORREF
:
指定显式RGB颜色时,COLORREF值具有以下十六进制形式:
0x00bbggrr
低位字节包含一个红色相对强度的值;第二个字节包含一个绿色值;和第三个字节包含蓝色的值。高阶字节必须为零。这个单个字节的最大值为0xFF。
要创建COLORREF颜色值,请使用RGB宏。提取颜色的红色、绿色和蓝色分量的单个值值,请使用GetRValue、GetGValue和GetBValue
我知道UInt32Array
,但我不知道如何使用它。
如何从COLORREF转换为RGB?
它应该与我发现的这个函数相反:
cssColorToCOLORREF: function(csscolor) {
let rgb = csscolor.substr(1);
let rr = rgb.substr(0, 2);
let gg = rgb.substr(2, 2);
let bb = rgb.substr(4, 2);
return parseInt("0x"+bb+gg+rr);
},
COLORREF
类型定义为DWORD
,这是Microsoft对32位无符号整数的名称,因此可以使用常规位操作将其值拆分为R、G、B、a组件。
作为阵列:
input = 4294967295;
output = [
input & 0xff,
(input >> 8) & 0xff,
(input >>16) & 0xff,
(input >>24) & 0xff
];
从而产生作为CCD_ 6的输出次序;或作为对象:
output = {
r: input & 0xff,
g:(input >> 8) & 0xff,
b:(input >>16) & 0xff,
a:(input >>24) & 0xff
};
产生output.r
、output.g
、output.b
和output.a
。
相关文章:
- 节点Js:How to catch a“;没有这样的文件或目录“;读取线模块出错
- jQuery AJAX write to XML
- grep in JQuery to C#
- how to convert html <div> to pdf
- Node.js - POST to iFrame?
- SVG xml to image
- Advantages to DOMParser vs template & innerHTML
- how to split a string with ','
- 如何使用RGB或HSL显示HWB/HSB/CMYK通道
- How to declare a Map containing certain properties with flow
- Php variable obj to js
- 如何在submit to sightly时将表单输入值作为参数传递给WCMUsePojo
- D3JS selectAll to append rect
- Javascript connect to websocket
- 从2D RGB阵列创建图像
- Underscore each to update collection
- 构建画布RGB值的2D阵列
- 在哪里可以找到R-to-JavaScript编译器
- COLORREF to RGB
- Converting RGB to HEX fails