Bitmap.GetPixel Keeps Giving Me An Error Message In C#
<pre><code>    List&lt;Bitmap&gt; bitrecord = new List&lt;Bitmap&gt;();
    List&lt;String&gt; filerecord = new List&lt;String&gt;();
    string tempfilewrite = "";

    private void timer1_Tick(object sender, EventArgs e)
    {
        this.Hide();
    }

    private void timer2_Tick(object sender, EventArgs e)
    {
        using (Bitmap bitrecorder = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height))
        {
            using (Graphics recordgraphics = Graphics.FromImage(bitrecorder))
            {
                recordgraphics.CopyFromScreen(new Point(0, 0), Point.Empty, Screen.PrimaryScreen.Bounds.Size);
            }
            bitrecord.Add(bitrecorder);
        }
    }

    private void timer3_Tick(object sender, EventArgs e)
    {
        for (int z = 1; z &lt; bitrecord.ToArray().Length; z++)
        {
            Bitmap bit = bitrecord[z];
            tempfilewrite = "" + z;
            for (int x = 1; x &lt; Screen.PrimaryScreen.Bounds.Width; x++)
            {
                for (int y = 1; y &lt; Screen.PrimaryScreen.Bounds.Height; y++)
                {
                    tempfilewrite += ", (" + x + ", " + y + ", " + bit.GetPixel(x, y).R + ", " + bit.GetPixel(x, y).G + ", " + bit.GetPixel(x, y).B + ")";
                }
            }
            filerecord.Add(tempfilewrite);
        }
        System.IO.File.WriteAllLines(@"C:\Public\WriteLines.txt", filerecord);
        timer3.Stop();
    }
}
</code></pre>

<p>Above is code for a program that is supposed to take several pictures of your desktop and save them in a text file. However, when I start the program, it gives me an error with System.ArgumentException on the line where I am getting pixels with bit.GetPixel(x, y). If anyone knows how to fix this problem, that would be awesome, thanks.</p>