Я пытаюсь найти координаты пикселя определенного цвета.
На данный момент у меня есть снимок экрана с изображением, но я не знаю, куда идти.
Существующий код:
public Form1()
{
InitializeComponent();
}
private Bitmap Img;
private void button2_Click(object sender, EventArgs e)
{
var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height,
PixelFormat.Format32bppArgb);
// Create a graphics object from the bitmap.
var gfxScreenshot = Graphics.FromImage(bmpScreenshot);
// Take the screenshot from the upper left corner to the right bottom corner.
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X,
Screen.PrimaryScreen.Bounds.Y,
0,
0,
Screen.PrimaryScreen.Bounds.Size,
CopyPixelOperation.SourceCopy);
// Save the screenshot to the specified path that the user has chosen.
bmpScreenshot.Save("Screenshot.png", ImageFormat.Png);
}
//Want to get the location of the colour: #AA00FF
private Point GetLocation()
{
Img = new Bitmap("Screenshot.png");
Point p = new Point(1, 1);
//This should read:
//p = Img.GetLocationOfPixel('FF00AA');
return p;
}