vb点虐 快速识别颜色的简单介绍
vb点虐 如何对图片实现颜色识别
没明白你意思,看看是这样么?Dim PGet As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(picture)for i=1 to picture.heightfor j=1 to picture.widthPGet .GetPixel(j, i)nextnext
创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站设计制作、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的黄山区网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
在vb点虐 中,如何获取Graphics中某一指定点(像素)的颜色值?(VB语言)
要使用GetPixel函数来取得像素的颜色值,代码如下:
1
2
3
4
5
private void button1_Click(object sender, EventArgs e)
{
Color color = new Bitmap(pictureBox1.Image).GetPixel(10, 10);
MessageBox.Show(color.ToString());
怎么用vb识别出图片任意一点的颜色值?
'API函数声明
Option Explicit
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, _
ByVal y As Long) As Long
Private Type POINTAPI '创建用户自定义的类型
x As Long '定义X的数据类型
y As Long '定义Y的数据类型
End Type
Private Sub Timer1_Timer()
Dim P1 As POINTAPI, h As Long, h1 As Long, r1 As Long
GetCursorPos P1
h1 = GetDC(h)
r1 = GetPixel(h1, P1.x, P1.y)
If r1 = -1 Then
BitBlt Picture1.hdc, 0, 0, 1, 1, h1, P1.x, P1.y, vbSrcCopy
r1 = Picture1.Point(0, 0)
Else
Picture1.PSet (0, 0), r1
End If
label2.Caption = Hex$(r1)
Picture1.BackColor = r1
End Sub
Private Sub Command1_Click()
End
End Sub
vb点虐 拾色器设计,要求:能获取图片任意位置的颜色
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
文章名称:vb点虐 快速识别颜色的简单介绍
地址分享:http://scyanting.com/article/ddesisg.html