日期:2014-05-19  浏览次数:20737 次

如何判断一个平面中有黑象素点??
如何用C#语言来编程 判断一个平面中有黑象素点?


------解决方案--------------------
对所有的像点做一个循环用Bitmap.GetPixel 方法来查一下是不是每个RGB都接近0值就是了.
------解决方案--------------------
Bitmap vBitmap = new Bitmap(@ "c:\temp\temp.bmp ");
bool existsBlack = false;
for (int i = 0; i < vBitmap.Width && !existsBlack; i++)
for (int j = 0; j < vBitmap.Height && !existsBlack; j++)
{
if (vBitmap.GetPixel(i, j).ToArgb() == Color.Black.ToArgb())
{
existsBlack = true;
break;
}
}
Text = existsBlack.ToString();

------解决方案--------------------
//建立屏幕Graphics
Graphics grpScreen = Graphics.FromHwnd(IntPtr.Zero);
//根据屏幕大小建立位图
Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height,grpScreen);