Erasing parts of an image

Discussion in 'iOS Programming' started by Urip, Jan 13, 2010.

  1. Urip macrumors newbie

    Joined:
    Oct 27, 2008
    #1
    Well, the situation goes as follows :cool:
    I have a CGImage (filled in black for all I care). Every once in a while, I want to erase a circle in a given position and size from the CGImage.
    In erasing I mean drawing a transparent circle in a specific position in the CGImage...
    I know I can create a mask image with the circle I want to erase, and mask the CGImage each time I want to erase some... but creating a mask image and a new context, and than drawing a new image to the context with masking each time it is very expensive operations.
    So I ask you, what is the most efficient way for me to do this?


    thanks!!
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    See if CGContextClearRect does the trick.

    Edit: actually that will require you remake a new context each time if you're using CGImages since they aren't mutable through Quartz. Depending on how you're using the image, you could make a CGLayerRef and then modify that and redraw it into your view.
     

Share This Page