Chintan-Dave/UIImageScanlineFloodfill — pull request #7 by gutoaraujo (2013-11-22 04:02:28+00:00)
Title: Fixes logic to get to y-1, y and y+1 byteIndex for antialiasing

Thanks for the great work on this project and for making it open source. In trying it out I bumped into some crashes in getColorCode similar to the one reported in issue #3 . The cause of the crash is byteIndex out of memory range of imageData. What's causing it seems to be a logic error in the way antialias calculates the byteIndex of y-1 and y+1.

If I understood it correctly, it is actually calculating a byteIndex row in excess when it gets to the height-1 line. So, when it gets to y==height-1 it looks for height+1 instead of y==height position. This gives a byteIndex looking for a position in memory that is == (height * width * 4) + x * bytesPerPixel. This is out of range so it crashes.

I made such changes and this issue seem to be solved. Let me know if this makes sense to you. Thanks again.