我有一个简单的程序,并且包含 System.Drawing,但我无法使用 GetPixel() 方法。它说它没有找到。这可能是什么原因?
using System.Drawing;
namespace isolatepixels
{
class Program
{
static void Main(string[] args)
{
System.Drawing.Image image1 = System.Drawing.Image.FromFile(@"C:\1.jpg");
int x, y;
// Loop through the images pixels to reset color.
for (x = 0; x < image1.Width; x++)
{
for (y = 0; y < image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
image1.SetPixel(x, y, newColor);
}
}
}
}
}