Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用位图正确循环像素扫描_C#_Bitmap - Fatal编程技术网

C# 如何使用位图正确循环像素扫描

C# 如何使用位图正确循环像素扫描,c#,bitmap,C#,Bitmap,这是我的代码: 使用系统; 使用System.Collections.Generic; 使用系统组件模型; 使用系统数据; 使用系统图; 使用System.IO; 使用System.Linq; 使用系统文本; 使用系统线程; 使用System.Threading.Tasks; 使用System.Windows.Forms; 名称空间测试 { 班级计划 { 公共静态布尔搜索像素(字符串十六进制代码) { 位图位图=新位图(Screen.PrimaryScreen.Bounds.Width,Scre

这是我的代码:

使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.IO;
使用System.Linq;
使用系统文本;
使用系统线程;
使用System.Threading.Tasks;
使用System.Windows.Forms;
名称空间测试
{
班级计划
{
公共静态布尔搜索像素(字符串十六进制代码)
{
位图位图=新位图(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height);
Graphics Graphics=Graphics.FromImage(位图作为图像);
graphics.CopyFromScreen(0,0,0,0,位图.Size);
Color desiredPixelColor=ColorTranslator.FromHtml(十六进制代码);
对于(int x=0;x

我试图循环像素识别,以便一旦检测到像素,就在控制台中写入内容。我不知道的是,如何才能使它正常工作。我知道这可能不是最快的方法,但每次我运行它,并且指定的颜色出现在屏幕上时,程序都不会检测到它。

使用调试器单步执行代码时会发生什么?它应该告诉你你需要知道的一切。为什么你要从Screen.PrimaryScreen.Bounds切换到SystemInformation.VirtualScreen?使用调试器查看虚拟屏幕参数是什么…签出。可能有帮助。@JQSOFT您能提供visual studio项目吗?这对我来说似乎真的很有用,但我无法让它发挥作用。顺便说一下,谢谢@JQSOFT哦,好吧,它现在似乎起作用了。但是当提到
var targetColor=…
时,我需要输入什么颜色代码?十六进制色码?