真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net取一個(gè)點(diǎn)顏色的簡(jiǎn)單介紹

VB.NET當(dāng)鼠標(biāo)停在屏幕任意地方,得到該點(diǎn)的顏色

我有個(gè)笨辦法,先用API抓圖到內(nèi)存里,然后再在根據(jù)你點(diǎn)鼠標(biāo)的屏幕工作區(qū)坐標(biāo),去那圖里取色。

創(chuàng)新互聯(lián)主要從事網(wǎng)站制作、成都網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)市中,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):13518219792

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

'抓圖所需的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)

......

'取點(diǎn)的顏色

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

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

關(guān)鍵就是這些你自己組合吧,你分給的太少了,很麻煩,恕我不幫你改全了。如果要仔細(xì)幫你改,請(qǐng)另開(kāi)高分貼,不要用新馬甲來(lái)

在vb.net中,如何獲取Graphics中某一指定點(diǎn)(像素)的顏色值?(VB語(yǔ)言)

要使用GetPixel函數(shù)來(lái)取得像素的顏色值,代碼如下:

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 對(duì)固定坐標(biāo)取色

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

復(fù)制當(dāng)前屏幕左上角位置(300,300)的一個(gè)點(diǎn),取其顏色

誰(shuí)能告訴我用vb取一個(gè)點(diǎn)的顏色值的那個(gè)函數(shù)是什么?謝謝!

' 全屏幕取色(anbert原創(chuàng))

' 在窗體上按住鼠標(biāo)不放,然后可以在整個(gè)屏幕移動(dòng)

' Label控件(就是標(biāo)簽)上會(huì)顯示取到的顏色,窗口標(biāo)題顯示顏色值

'

' 新建一個(gè)窗體,添加一個(gè)Label控件,名字叫Label1

' 然后添加以下代碼

'

Option Explicit

'聲明API

Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint 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 Declare Function GetCursorPos Lib "user32" (lpPoint As POINT) As Long

Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINT) As Long

Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long

'自定義一個(gè)類型

Private Type POINT

X As Long

Y As Long

End Type

'取到的顏色保存在這里

Dim theColor As Long

'按下鼠標(biāo)時(shí)指針變成十字型

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Me.MousePointer = 2

End Sub

'全屏幕取色

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

On Error Resume Next

If Button 1 Then Exit Sub

Dim pos As POINT

GetCursorPos pos

Dim hdc As Long, dc As Long

hdc = WindowFromPoint(pos.X, pos.Y)

ScreenToClient hdc, pos

dc = GetDC(hdc)

theColor = GetPixel(dc, pos.X, pos.Y)

Me.Caption = CStr(theColor)

Debug.Print "Color:" CStr(theColor) vbCrLf

Label1.BackColor = theColor

End Sub

'松開(kāi)鼠標(biāo)時(shí)指針變成默認(rèn)

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)

Me.MousePointer = 0

End Sub

VB.NET:繪圖后,如何才能取得所繪圖形的顏色值?

加入一個(gè)TextBox控件,一個(gè)Command控件

代碼:

Private Declare Function GetPixel Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long) As Long

Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long

Private Sub Command1_Click()

Dim Color As Long

WindowDC = GetWindowDC(0) '獲取屏幕的設(shè)備場(chǎng)景

Color = GetPixel(WindowDC, 500, 100) '獲指定點(diǎn)的顏色

'分解RGB顏色值

R = (Color Mod 256) '紅色

b = (Int(Color \ 65536)) '藍(lán)色

G = ((Color - (b * 65536) - R) \ 256) '綠色

Text1.BackColor = RGB(R, G, b)

End Sub


網(wǎng)頁(yè)題目:vb.net取一個(gè)點(diǎn)顏色的簡(jiǎn)單介紹
鏈接分享:http://weahome.cn/article/docjsgj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部