VB进行RGB分色

Option Explicit

Private Type RGBA
R As Byte
G As Byte
B As Byte
A As Byte
End Type
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal y As Long) As RGBA Private Sub Command1_Click()
Dim cor As RGBA
'用GetPixel取色,直接就分出来,注意看GetPixel声明的返回类型
cor = GetPixel(Me.hdc, , )
Print cor.R, cor.G, cor.B
End Sub Private Sub Command2_Click()
Dim cor As RGBA
Dim MeColor As Long
MeColor = Me.BackColor
'分离RGB
CopyMemory cor, MeColor,
Print cor.R, cor.G, cor.B
'转回整形颜色值
CopyMemory MeColor, cor,
Print MeColor
End Sub
上一篇:开源ERP Odoo仓存功能模块深度应用(一)


下一篇:Python数据类型