如何获取调色板的RGB属性? 谢谢
请问有谁知道 如何获取调色板的RGB属性?
例如:
我已经在调色板里面选择了一种颜色
怎样才能获得 所选择的颜色的 RGB 值?
请高手给指点下 谢谢
[解决办法]
Option Explicit
Dim c As Long
Dim red As Byte
Dim green As Byte
Dim blue As Byte
Private Sub Command1_Click()
On Error Resume Next
CommonDialog1.CancelError = True
CommonDialog1.DialogTitle = "颜色"
CommonDialog1.ShowColor
If Err <> 32755 Then
c = CommonDialog1.Color
red = (c And &HFF)
green = (c And 62580) / 256
blue = (c And &HFF00) / 65536
Label1 = red
Label2 = green
Label3 = blue
End If
End Sub
Option Explicit
Dim c As Long
Dim red As Byte
Dim green As Byte
Dim blue As Byte
Private Sub Command1_Click()
On Error Resume Next
CommonDialog1.CancelError = True
CommonDialog1.DialogTitle = "颜色"
CommonDialog1.ShowColor
If Err <> 32755 Then
c = CommonDialog1.Color
red = (c Mod 65536) Mod 256 'Red
green = (c Mod 65536) \ 256 'Green
blue = c \ 65536 'Blue
'red = (c And &HFF)
'green = (c And 62580) / 256
'blue = (c And &HFF00) / 65536
Shape1.FillColor = RGB(red, green, blue)
Label1 = red
Label2 = green
Label3 = blue
End If
End Sub