Your inner loop goes from 0
to 3
, instead of 0
to input.Height
. This will produce an out of range exception when input.Height < 3
.
You probably meant to do this:
field = new int[input.Width][][];
for (int x = 0; x < input.Width; x++)
{
field[x] = new int[input.Height][];
for (int y = 0; y < input.Height; y++)
{
field[x][y] = new int[3];
}
}