VB怎么取图片指定点的颜色?
一张尺寸800*600的JPEG图片,怎么能识别出图片中心位置那个点的颜色,我现在用的point方法,研究一晚上都没取对,哪位高人告诉下该怎么用point取或者还有什么更...
一张尺寸800*600的JPEG图片,怎么能识别出图片中心位置那个点的颜色,我现在用的point方法,研究一晚上都没取对,哪位高人告诉下该怎么用point取或者还有什么更好的方法?
展开
2个回答
推荐于2017-09-21 · 知道合伙人软件行家
关注
展开全部
VB可使用Point方法来获取图片指定点的颜色。
Point 方法
按照长整数,返回在 Form 或 PictureBox 上所指定磅的红-绿-蓝 (RGB) 颜色。
语法
object.Point(x, y)
'窗体判色代码:
Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1 = X
Text2 = Y
Text3 = Point(X, Y)
Text4 = (Val(Text3) Mod 65536) Mod 256 'Red
Text5 = (Val(Text3) Mod 65536) \ 256 'Green
Text6 = Val(Text3) \ 65536 'Blue
Shape1.FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))
End Sub
'PictureBox判色代码:
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1 = X
Text2 = Y
Text3 = Picture1.Point(X, Y)
Text4 = (Val(Text3) Mod 65536) Mod 256 'Red
Text5 = (Val(Text3) Mod 65536) \ 256 'Green
Text6 = Val(Text3) \ 65536 'Blue
Shape1.FillColor = RGB(Val(Text4), Val(Text5), Val(Text6))
End Sub
展开全部
Option Explicit
Private Sub Form_Load()
Picture1.AutoSize = True
Picture1.Picture = LoadPicture("D:\我的文档\My Pictures\美女\mai.jpg")
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim c$, r%, g%, b%
On Error Resume Next
c = Hex(Picture1.Point(X, Y))
r = "&H" & Right(c, 2): g = "&H" & Mid(c, Len(c) - 3, 2): b = "&H" & Mid(c, Len(c) - 5, 2)
Me.BackColor = RGB(r, g, b)
End Sub
Private Sub Command1_Click() '中心点颜色
Dim c$, r%, g%, b%
On Error Resume Next
c = Hex(Picture1.Point(Picture1.ScaleWidth * 0.5, Picture1.ScaleHeight * 0.5))
r = "&H" & Right(c, 2): g = "&H" & Mid(c, Len(c) - 3, 2): b = "&H" & Mid(c, Len(c) - 5, 2)
Me.BackColor = RGB(r, g, b)
End Sub
Private Sub Form_Load()
Picture1.AutoSize = True
Picture1.Picture = LoadPicture("D:\我的文档\My Pictures\美女\mai.jpg")
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim c$, r%, g%, b%
On Error Resume Next
c = Hex(Picture1.Point(X, Y))
r = "&H" & Right(c, 2): g = "&H" & Mid(c, Len(c) - 3, 2): b = "&H" & Mid(c, Len(c) - 5, 2)
Me.BackColor = RGB(r, g, b)
End Sub
Private Sub Command1_Click() '中心点颜色
Dim c$, r%, g%, b%
On Error Resume Next
c = Hex(Picture1.Point(Picture1.ScaleWidth * 0.5, Picture1.ScaleHeight * 0.5))
r = "&H" & Right(c, 2): g = "&H" & Mid(c, Len(c) - 3, 2): b = "&H" & Mid(c, Len(c) - 5, 2)
Me.BackColor = RGB(r, g, b)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询