大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
我有个笨办法,先用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)
----------------------------
关键就是这些你自己组合吧,你分给的太少了,很麻烦,恕我不帮你改全了。如果要仔细帮你改,请另开高分贴,不要用新马甲来
你的那个图像控件叫什么?是第三方控件的话要看说明了
一般用Picture控件就可以了啊
[DllImport("user32.dll", EntryPoint = "GetDC")]
public static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
先找到你要截图的那个窗体的 句柄 然后根据这个句柄得到改窗体的DC 创建一个bitmap 然后填充 得到的bitmap后 显示到picturebox里面