大橙子网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb.net屏幕取色,vb获取屏幕颜色值

vb.net拾色器设计,要求:能获取图片任意位置的颜色

VB可使用Point方法来获取图片指定点的颜色。

10年积累的网站设计、成都网站设计经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有连江免费网站建设让你可以放心的选择与我们合作。

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.net 对固定坐标取色

Using b As New Bitmap(1, 1)

Using g As Graphics = Graphics.FromImage(b)

g.CopyFromScreen(New Point(300, 300), New Point, New Size(1, 1))

PictureBox1.BackColor = b.GetPixel(0, 0)

End Using

End Using

复制当前屏幕左上角位置(300,300)的一个点,取其颜色

VB.NET当鼠标停在屏幕任意地方,得到该点的颜色

我有个笨办法,先用API抓图到内存里,然后再在根据你点鼠标的屏幕工作区坐标,去那图里取色。

-----------------------

'抓图所需的API

Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Integer) As Integer

Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer) As Integer

Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Integer, ByVal hObject As Integer) As Integer

Private Declare Function BitBlt Lib "GDI32" (ByVal srchDC As Integer, ByVal srcX As Integer, ByVal srcY As Integer, ByVal srcW As Integer, ByVal srcH As Integer, ByVal desthDC As Integer, ByVal destX As Integer, ByVal destY As Integer, ByVal op As Integer) As Integer

Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Integer) As Integer

Private Declare Function DeleteObject Lib "GDI32" (ByVal hObj As Integer) As Integer

Declare Function GetDC Lib "user32" Alias "GetDC" (ByVal hwnd As Integer) As Integer

Const SRCCOPY As Integer = HCC0020

'抓图的部分

Dim hDC, hMDC As Integer

Dim hBMP, hBMPOld As Integer

Dim sw, sh As Integer

hDC = GetDC(0)

hMDC = CreateCompatibleDC(hDC)

sw = Screen.PrimaryScreen.Bounds.Width

sh = Screen.PrimaryScreen.Bounds.Height

hBMP = CreateCompatibleBitmap(hDC, sw, sh)

hBMPOld = SelectObject(hMDC, hBMP)

BitBlt(hMDC, 0, 0, sw, sh, hDC, 0, 0, SRCCOPY)

hBMP = SelectObject(hMDC, hBMPOld)

Dim bmp As Bitmap = Image.FromHbitmap(New IntPtr(hBMP))

DeleteDC(hDC)

DeleteDC(hMDC)

DeleteObject(hBMP)

......

'取点的颜色

bmp.GetPixel(e.X, e.Y)

----------------------------

关键就是这些你自己组合吧,你分给的太少了,很麻烦,恕我不帮你改全了。如果要仔细帮你改,请另开高分贴,不要用新马甲来

在vb.net中,如何获取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.net屏幕取色,vb获取屏幕颜色值
当前网址:http://dzwzjz.com/article/hocpdc.html
在线咨询
服务热线
服务热线:028-86922220
TOP