• This repository has been archived on 16/Mar/2021
  • Stars
    star
    158
  • Rank 236,278 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is an Objective-C implementation of Scanline Flood Fill Algorithm.

UIImageScanlineFloodfill

This is an Objective-C implementation of Scanline Flood Fill Algorithm.

Before Flood Fill After Flood Fill

I have used Scanline Floodfill Algorithm because it is faster than 4 way and 8 way. Implement using iterative logic because iPhone have very limite capicity compare to computeer and recursive implementation make stackoverflow exception.

I have try my best to make it fast but it is still in its beginning phase so any suggestion and contribution is welcome.

This is part of my iOS drawing app.

When I search for flood fil on internet I found that there are many implementation for c, c#, Java etc. but for Objective - C there are only 2 or 3 implementation and not very easy to understand.

So I decide to share my work.

I would like to thanks:

How It Work ?

For Implementation detail visit : Scanline Flood Fill Algorithm with (or without) Tolerance in Objective-C

How To Use It:

If you wan to use this directly in your project that do as follow:

  1. Copy Folllowing file in your project
    1. LinkedListStack.h
    2. LinkedListStack.m
    3. UIImage+FloodFill.h
    4. UIImage+FloodFill.m
  2. UIImage+FloodFill.h file where you want to use this .
  3. Call flood fill function with all argument like folloeing

UIImage *image1 = [self.image floodFillFromPoint:tpoint withColor:[UIColor grayColor] andTolerance:tolerance];

Limitation(s)

We have some hard time dealing with the Alpha channel (transparency). We are still working on that.
As a workground right now we are replacinng Alpha to White color by converting an image to JPEG.
If you don't want to use this behaviour you can comment (Or Remove) frollowinng method from FloodFillImageView
- (void)setImage:(UIImage *)image

License : MIT LICENSE FILE