作者Achui (Eagle)
看板Visual_Basic
標題[VB6 ] 螢幕區域取色問題
時間Fri Nov 29 00:56:57 2013
看過人家寫的滑鼠取色程式(秀出RGB值),
有辦法修改成以滑鼠為中心的100x100 pixels 區域,然後及時秀出區域內的平均RGB值嗎
Dim ColorRGB As Long
Dim IsFlow As Boolean
Private Sub Form_DblClick()
End
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
ColorRGB = Form2.Point(X, Y)
Call GetRGB(X, Y)
End Sub
Private Sub GetRGB(X As Single, Y As Single)
Dim r As Integer, g As Integer, b As Integer
Dim r1 As String, g1 As String, b1 As String
If IsFlow Then
If X > Form2.Width / 2 Then Frame1.Left = X - Frame1.Width - 100
If Y > Form2.Height / 2 Then Frame1.Top = Y - Frame1.Height - 100
If X <= Form2.Width / 2 Then Frame1.Left = X + 100
If Y <= Form2.Height / 2 Then Frame1.Top = Y + 100
End If
Shape1.FillStyle = 0
Shape1.FillColor = ColorRGB
r = ColorRGB Mod 256
g = ColorRGB \ 256 Mod 256
b = ColorRGB \ 256 \ 256
LblcolorR.Caption = r
LblcolorG.Caption = g
LblcolorB.Caption = b
r1 = IIf(r <> 0, Hex(r), "00")
g1 = IIf(g <> 0, Hex(g), "00")
b1 = IIf(b <> 0, Hex(b), "00")
TxtColor.Text = "#" & r1 & g1 & b1
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y
As Single)
If Button = 1 Then IsFlow = True Else IsFlow = False
End Sub
Private Sub Label2_Click()
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If X Mod 150 <> 0 And Y Mod 150 <> 0 Then
ColorRGB = Picture1.Point(X, Y)
Call GetRGB(X, Y)
End If
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.132.80.215
1F:→ MOONRAKER:有 11/29 11:12
2F:推 hayabusasean:GetCursorPos,GetPixel,取所有顏色long值avg再分RGB? 12/03 11:35