1

I have an PNG image with complete transparency. It has a picture of an animal , just bordered with black color.

Now , I want to paint the image as my finger move on the ipad Screen, but paint should only appear inside the bordered region not out side.

My Thinking -----

What i am thinking is to keep the color of the image inside the boundary line, a little bit differ from the out side. Then, Get the pixel of the image and for each pixel , the color component.

Keeping all the pixels of out side the boundary in an array and check for it when finger move on the iPad screen.

I am new to the concept of core graphic and open GL so not being able to think wisely. Please help.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
ankit
  • 113
  • 2
  • 8

1 Answers1

1

First you should define where is "inside" to paint on your image. I suggest to run a flood fill algortihm on the first touched place and define de desired "inside area" pixels. Notice that you will run the flood fill at the background on the original black and white image, not for actually painting the pixels, just to figure out the target ones.

For example; we want to paint the animals face and body to different colors. When user first toucehs the face and drags over, you can do a flood fill on black and white image to find the pixels of the face and only paint the intersection of the face area and the touched area. Then, when the user picks up her finger (changes the color) and retouches on the body and you do another flood fill operation to detect the pixels of the body and so on.

It was a long description, hope it makes sense.

Here are some flood fill sources that might help:

Floodfill in objective c

https://stackoverflow.com/questions/8121348/flood-fill-algorithm-objective-c-version

How to Implement FloodFill Algorithm in iphone

Community
  • 1
  • 1
bmkorkut
  • 616
  • 5
  • 17