views:

38

answers:

0

I'm implementing custom view which will provide image editing functionality (like filling with color, hand drawing etc). View initialized with image (pgn, jpg whatever), and user can modify it.

I'm not sure how it will be good to implement.

At the moment every drawRect I draw UIImage *mainImage.

During events like touchesEnded:withEvent or touchesMoved:withEvent I draw in the context and save it in the mainImage object. After that call setNeedsDisplay.

For filling algorithm I extract bytes from the CGContext with CGBitmapContextGetData, fill with implemented algorithm (didn't find any standard way, so implemented from scratch) and save result to the mainImage object by CGImageCreate. After that call setNeedsDisplay.

I'm very sure this is wrong way, but I don't see really alternatives..