匹配颜色
来源:互联网 发布:西华师范大学知乎 编辑:程序博客网 时间:2024/04/29 18:03
private static Bitmap GetScreenShot()
{
Bitmap result = new Bitmap(Screen.PrimaryScreen.Bounds.Width
, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
{
using (Graphics gfx = Graphics.FromImage(result))
{
gfx.CopyFromScreen(Screen.PrimaryScreen.Bounds.X
, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
}
}
return result;
}
private static Point[] FindColor(Color color)
{
int searchValue = color.ToArgb();
List<Point> result = new List<Point>();
using (Bitmap bmp = GetScreenShot())
{
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
if (searchValue.Equals(bmp.GetPixel(x, y).ToArgb()))
result.Add(new Point(x, y));
}
}
}
return result.ToArray();
}
private void button1_Click(object sender, EventArgs e)
{
Point[] points = FindColor(label1.BackColor);
if (points.Length > 0)
Cursor.Position = points[0];
}
{
Bitmap result = new Bitmap(Screen.PrimaryScreen.Bounds.Width
, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
{
using (Graphics gfx = Graphics.FromImage(result))
{
gfx.CopyFromScreen(Screen.PrimaryScreen.Bounds.X
, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
}
}
return result;
}
private static Point[] FindColor(Color color)
{
int searchValue = color.ToArgb();
List<Point> result = new List<Point>();
using (Bitmap bmp = GetScreenShot())
{
for (int x = 0; x < bmp.Width; x++)
{
for (int y = 0; y < bmp.Height; y++)
{
if (searchValue.Equals(bmp.GetPixel(x, y).ToArgb()))
result.Add(new Point(x, y));
}
}
}
return result.ToArray();
}
private void button1_Click(object sender, EventArgs e)
{
Point[] points = FindColor(label1.BackColor);
if (points.Length > 0)
Cursor.Position = points[0];
}
0 0
- 匹配颜色
- 颜色匹配
- 更改MyEclipse匹配颜色
- 颜色匹配实验
- css颜色匹配代码
- 颜色匹配 Matlab版本
- 颜色匹配 opencv版
- 颜色直方图匹配(一)
- 颜色匹配与腐蚀中心
- 谈谈iOS下图像颜色检测、颜色匹配的解决方法
- 谈谈iOS下图像颜色检测、颜色匹配的解决方法
- iOS下图像颜色检测、颜色匹配的解决方法
- 谈谈iOS下图像颜色检测、颜色匹配的解决方法
- Photoshop CS5 轻松匹配图像颜色
- myeclipse中设置括号匹配颜色
- Eclipse修改括号匹配的颜色
- VBA 宏 匹配以及单元格颜色
- Eclipse修改括号匹配的颜色
- Ubuntu下LAMP安装配置
- lua的模式匹配
- How to install PostGIS 2.0 on Ubuntu 11.10 (oneiric) from source
- Cocos2d-x3.0源码分析之跨平台适配层
- 机器学习入门阶段程序员易犯的5个错误
- 匹配颜色
- 学习一
- 手机UserAgent数据(不定期补充)
- android-Acitvity之间数据的传递
- java的锁
- 唯品会Microscope——大规模分布式系统的跟踪、监控、告警平台
- java中(PO,VO,TO,BO,DAO,DTO,QO,POJO)等概念的理解
- 排序算法的相关介绍
- 单元测试用例设计原则