02-28-2012، 01:54 AM
با کد زیر میتونید با حرکت ماوس رنگ پیکسل رو بدت بیارید و تبدلش کنید به rgb
کد:
Parameter Information
Public Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Code
Dim PixCol As Long
Private Sub Command1_Click()
'End the app
Unload Me
End
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
'Get the pixel color
PixCol = GetPixel(Picture1.hdc, x, y)
'Convert to RGB
r = PixCol Mod 256
b = Int(PixCol / 65536)
g = (PixCol - (b * 65536) - r) / 256
'Add to the labels
Label1.Caption = "R=" & r
Label2.Caption = "G=" & g
Label3.Caption = "B=" & b
'Change Picture2's backcolor
Picture2.BackColor = RGB(r, g, b)
End Sub