The problem you're having is you're not compensating for the extra pixel in the border. Another thing, you should consider using a 2d array instead of what you have set up.


1,0,1,0,1,0,1,0,...