Punching holes into IKImageView

  • I have an IKImageView and would like to create holes, i.e. set alpha to zero in some rectangle.
    And then save the result in some format.

    What would be the easiest way to do this?

    1. Create a CIFilter and do:
    myIkImageView.imageCorrection = myHoleFIlter
    save myIkImageView

    2.
    CGImageRef cgImage = [ myIkImageView image ];
    NSBitmapImageRep  *bp = [ [NSBitmapImageRep alloc ] initWithCGImage: cgImage];
    NSColor *c = [ NSColor clearColor];
    for the intended rectangle do: [ bp setColor: c atX: ... y: ...];
    CGImageRef new = [ bp CGImage ];
    [ myIkImageView setImage: new  imageProperties: ...];
    save myIkImageView

    3.    Something else? Maybe just use an existing filter (CISourceOverCompositing ?) to put a clear rectangle on top?

    Efficiency is not the prime concern. It would be acceptable if it takes a few seconds to create a hole.
    I have no experience with CIFilter yet.

    Kind regards,

    Gerriet.
previous month april 2010 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today