论坛帮助 |
社区圈子 |
日历事件 |
2020-12-07, 12:00 | #1 | |||
|
||||
正式会员
等级: 七袋长老
|
引用:
Public Function LABtoRGB(l, a, b, n) Dim fx, fy, fz, rr, gg, bb, r, g, B2 As Double fy = ((l + 16) / 116) ^ 3 If fy < 0.008856 Then fy = l / 903.3 Y = fy If fy > 0.008856 Then fy = fy ^ (1 / 3) Else fy = 7.787 * fy + 16 / 116 End If fx = a / 500 + fy If fx > 0.206893 Then x = fx ^ 3 Else x = (fx - 16 / 116) / 7.787 End If fz = fy - b / 200 If fz > 0.206893 Then z = fz ^ 3 Else z = (fz - 16 / 116) / 7.787 End If x = x * (0.950456 * 255) Y = Y * 255 z = z * (1.088754 * 255) rr = 3.240479 * x - 1.53715 * Y - 0.498535 * z gg = -0.969256 * x + 1.875992 * Y + 0.041556 * z bb = 0.055648 * x - 0.204043 * Y + 1.057311 * z r = IIf(rr < 0, 0, IIf(rr > 255, 255, rr)) g = IIf(gg < 0, 0, IIf(gg > 255, 255, gg)) B2 = IIf(bb < 0, 0, IIf(bb > 255, 255, bb)) If n = 1 Then arr = Array(r, g, B2) LABtoRGB = arr(0) End If If n = 2 Then arr = Array(r, g, B2) LABtoRGB = arr(1) End If If n = 3 Then arr = Array(r, g, B2) LABtoRGB = arr(2) End If End Function 说明:1,是R;2,是G,3 是B |
|||
右列会员因为此帖价值甚高向 重庆印刷工 表示感谢: |
yzx0120 (2020-12-11)
|