views:

266

answers:

2

There are two images. image1 and image2. I have added image2 on image1. Overall the output image must be image1 only but, the portion of the image2 must become transparent. I mean the alpha values on the intersection area must be in reverse order( i.e, if alpha value of one pixel( say 120, 100) on image2 is 1.0 then the same pixel's alpha value on image1 must become 0. If it is 0.6 then it must become 0.4).

A: 

Try xor mode.

Rhythmic Fistman
A: 

It sounds like you're trying to use image2 as a mask for image 1. In Quartz, you can create an image mask and then make subsequent drawing operations use the mask's alpha value as a multiplier. I don't think there's a straightforward XOR more, though.

Good Luck!

Ben Gotow
“kCGBlendModeXOR:R = S*(1 - Da) + D*(1 - Sa). This XOR mode is only nominally related to the classical bitmap XOR operation, which is not supported by Quartz 2D.Available in iPhone OS 2.0 and later.” — http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/doc/c_ref/kCGBlendModeXOR
Peter Hosey