VB2005 中 如何将某一像素点的R、G、B值分别提取出来?
我也曾在网上查过pixel(x,y)和pixel(GetDC(0),x,y),可是将这些相关函数写入VB2005后,居然提示没有GetDC(0)和Pixel(x,y).还...
我也曾在网上查过pixel(x,y)和pixel(GetDC(0),x,y),可是将这些相关函数写入VB2005后,居然提示没有GetDC(0)和Pixel(x,y).还请各位高手指点
展开
展开全部
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If Me.PictureBox1.Image Is Nothing Then '如果PictureBox1.Image is nothing,退出
Exit Sub
End If
Dim btp As Bitmap = PictureBox1.Image
Dim c As Color = btp.GetPixel(e.X, e.Y)
Label1.Text = c.R '显示R
Label2.Text = c.G '显示G
Label3.Text = c.G '显示B
End Sub
If Me.PictureBox1.Image Is Nothing Then '如果PictureBox1.Image is nothing,退出
Exit Sub
End If
Dim btp As Bitmap = PictureBox1.Image
Dim c As Color = btp.GetPixel(e.X, e.Y)
Label1.Text = c.R '显示R
Label2.Text = c.G '显示G
Label3.Text = c.G '显示B
End Sub
展开全部
'''Return Type: COLORREF->DWORD->unsigned int
'''hdc: HDC->HDC__*
'''x: int
'''y: int
<System.Runtime.InteropServices.DllImportAttribute("gdi32.dll", EntryPoint:="GetPixel")> _
Public Shared Function GetPixel(<System.Runtime.InteropServices.InAttribute()> ByVal hdc As System.IntPtr, ByVal x As Integer, ByVal y As Integer) As UInteger
End Function
windows API 万能产品
'''hdc: HDC->HDC__*
'''x: int
'''y: int
<System.Runtime.InteropServices.DllImportAttribute("gdi32.dll", EntryPoint:="GetPixel")> _
Public Shared Function GetPixel(<System.Runtime.InteropServices.InAttribute()> ByVal hdc As System.IntPtr, ByVal x As Integer, ByVal y As Integer) As UInteger
End Function
windows API 万能产品
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim ac as color
...ac=...
dim rr as interger=ac .r
dim gg as interger=ac .g
dim bb as interger=ac b
...ac=...
dim rr as interger=ac .r
dim gg as interger=ac .g
dim bb as interger=ac b
追问
谢谢你的解答!我想在Picturebox控件载入一幅图片,当鼠标在这幅图片上移动时,能将鼠标实时位置处的RGB值显示在label中,麻烦你把这部分的程序再写完整一些,多谢了!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询