// x,y 分别为x轴,y轴坐标 返回System.Drawing.Color 可以直接显示 public System.Drawing.Color GetPixelColor(int x,int y) { IntPtr hdc = GetDC(IntPtr.Zero); uint pixel = GetPixel(hdc,x,y); ReleaseDC(IntPtr.Zero,hdc); Color color = Color.FromArgb((int)(pixel & 0x000000FF),(int)(pixel & 0x0000FF00) >> 8,(int)(pixel & 0x00FF0000) >> 16); return color; } //定义一个定时器 获取当前坐标上的像素点颜色 private void timer_Tick(object sender,EventArgs e) { textBox1.Text = GetPixelColor(Cursor.Position.X,Cursor.Position.Y).R.ToString() + " " + GetPixelColor(Cursor.Position.X,Cursor.Position.Y).G.ToString() + " " + GetPixelColor(Cursor.Position.X,Cursor.Position.Y).B.ToString(); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。