我想读取屏幕的一部分的平均亮度,作为组件的总和。我正在捕捉屏幕:
private void DirSearch(String sDir,String outFolder)
{
try
{
String[] files;
String[] dirs;
while(true){
if(Directory.Exists(sDir)){
files = Directory.GetFiles(sDir);
dirs = Directory.GetDirectories(sDir);
break;
}
}
foreach (string f in files)
{
goRun(f,outFolder);
}
foreach (string d in dirs)
{
if(!Path.GetFileName(d).Equals("outputFolder")) DirSearch(d,outFolder);
}
}
catch (System.Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.ToString());
}
}
private void goRun(String path,String outFolder){
String[] fileLines;
String firstPath = Path.Combine(outFolder,"out1.txt")
String secondPath = Path.Combine(outFolder,"out2.txt")
while(true){
if(File.Exists(path)){
fileLines = File.ReadAllLines(path);
break;
}
}
//do something
while(true){
if(Directory.Exists(outFolder)){
File.WriteAllLines(outputPath, outputOne);
File.WriteAllLines(secondPath, outputTwo);
break;
}
}
}
如何将屏幕的一部分复制到缓冲区中,然后检查其每个元素以评估其颜色成分。