c#获取屏幕上某坐标点的颜色
2017-10-04 09:56
519 查看
全栈工程师开发手册 (作者:栾鹏)
c#教程全解
c#获取屏幕上某坐标点的颜色
c#教程全解
c#获取屏幕上某坐标点的颜色
using System.Runtime.InteropServices; private struct POINT { private int x; private int y; } static POINT point; [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] private static extern int GetDC(int hwnd); [DllImport("gdi32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] private static extern int GetPixel(int hdc, int x, int y); [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] private static extern int ReleaseDC(int hwnd, int hdc); [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] private static extern int WindowFromPoint(int x, int y); [DllImport("user32", ExactSpelling = true, CharSet = CharSet.Ansi, SetLastError = true)] private static extern int ScreenToClient(int hwnd, ref POINT lppoint); //获取屏幕指定坐标点的颜色 public static Color GetPixelColor(int x, int y) { int h = WindowFromPoint(x, y); int hdc = GetDC(h); ScreenToClient(h, ref point); int c = GetPixel(hdc, x, y); return Color.FromArgb(c); }
相关文章推荐
- C#简单获取屏幕鼠标坐标点颜色方法介绍
- C#简单获取屏幕鼠标坐标点颜色
- C#简单获取屏幕鼠标坐标点颜色方法介绍
- C# 获取鼠标在屏幕中的颜色和位置
- 获取鼠标在屏幕上的坐标和颜色值(RGB)
- C#动态获取当前屏幕中光标所在位置的颜色
- Android 获取屏幕指定坐标的颜色
- java获取屏幕上某坐标点的颜色
- C#获取屏幕鼠标所指点的颜色
- c#中获取屏幕上鼠标的坐标
- C#中使用GetCursorPos获取屏幕坐标
- C#中使用GetCursorPos获取屏幕坐标
- C#中使用GetCursorPos获取屏幕坐标
- C# 获取光标在屏幕上的位置
- js获取div相对屏幕的坐标位置
- C#的百度地图开发(三)依据坐标获取位置、商圈及周边信息
- Qt实用技巧:在Qt中获取屏幕的绝对坐标
- 如何获取屏幕上各颜色的红、绿、蓝值
- 动态获取当前屏幕中光标所在位置的颜色
- android 获取屏幕宽高 和 获取控件坐标