1

I am using a GetPixel function to take a pixel from the screen and return its colour:

int GetPixel(int X, int Y)
    {
        Bitmap bmp = new Bitmap(1, 1, PixelFormat.Format32bppPArgb);
        Graphics grp = Graphics.FromImage(bmp);
        grp.CopyFromScreen(new Point(X, Y), Point.Empty, new Size(1, 1));
        grp.Save();

        return bmp.GetPixel(0, 0).ToArgb();
    }

It works well but calling the function 5 times per sec to get 5 different pixel colours seems to drop my fps by 10-15. Is there a more efficient way to use CopyFromScreen?

jcarder
  • 124
  • 3
  • 16

0 Answers0