Comment out all the other irrelevant code in the loop and other irrelevent code after the loop so that only this remains.
for(i=0;i<=a.Height;i++)
{<blockquote>for(j=0;j<=a.Width;j++)
{<blockquote>Color c=a.GetPixel(i,j);</blockquote>}</blockquote>}
See if the error comes up again. If not, keep on adding lines until you get the error, and try to see what are the values of i and j this happens.