Make sure to never generate border pixels if b is zero. Without this, a border pixel can be generated even with zero b, if a pixel centre is precisely on the border.