Fatsest way to edit alpha of CGImage (or UIImage) with touch and then display?

Posted by Pankaj on Stack Overflow See other posts from Stack Overflow or by Pankaj
Published on 2010-05-09T06:40:39Z Indexed on 2010/05/09 6:48 UTC
Read the original article Hit count: 253

Filed under:
|
|
|
|

I have two image views, one on top of the another, with two different images. As the user touches the image and moves his/her finger, the top image should become transparent along the touch points with a fixed radius. (Like the PhotoChop app).

Currently I am doing it this way...

  1. For each touch.
  2. Get a copy of the image buffer from CGImage of the top image.
  3. Edit the alpha channel of the buffer to create a transparent circle centered at the touch point.
  4. Create new CGImage from the buffer.
  5. Create UIImage from the CGImage and use the new UIImage as the top image view's image.

This works but as you can see too many copy, creates are involved and it is slow.

Can somebody please suggest me a faster way of doing the same thing?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about cgimage