Before use Flood Fill After Using Flood Fill
I have used Scanline Floodfill Algorithm because it is faster than 4 way and 8 way.
And implement using iterative logic because iPhone have very limite capicity compare to computera and recursive implementation make stackover flow exception.
This is part of my iOS drawing app.
When I search for flood fil on google I found that there are many implementation for c, c#, Java
But for Objective - C there are oonly 2 or 3 implementation and not very easy to understand.
So I decide to share my work.
- How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)
- A Faster Array in Objective-c
- Lode's Computer Graphics Tutorial Flood Fill
For Implementation detail visit : Scanline Flood Fill Algorithm with (or without) Tolerance in Objective-C
If you wan to use this directly in your project that do as follow:
-
Copy Folllowing file in your project
-
LinkedListStack.h
-
LinkedListStack.m
-
UIImage+FloodFill.h
-
UIImage+FloodFill.m
-
-
UIImage+FloodFill.h
file where you want to use this . - Call flood fill function with all argument like folloeing
UIImage *image1 = [self.image floodFillFromPoint:tpoint withColor:[UIColor grayColor] andTolerance:tolerance];