0

Possible Duplicate:
Merge and wrap UIImage on mug

i have two image and i want to merge those two images like i have a image of mug and second image is any image now i want to merge with it to mug how could i achieve this enter image description here

now suppose cup is totally white and than i merge the other image with on it how should i achieve this ????

Community
  • 1
  • 1
Muzamil Hassan
  • 841
  • 1
  • 11
  • 23
  • Do you just want to display both images one on top of the other onscreen? Or do you want to generate a new binary file containing the overlay? – The dude Jul 26 '12 at 08:30

1 Answers1

1

Well you could make a custom UIView and override the - (void)drawRect:(CGRect)rect and write something like this:

CGContextRef con = UIGraphicsGetCurrentContext();
[self.img1 drawInRect:self.bounds blendMode:kCGBlendModeNormal alpha:1];
[self.img2 drawInRect:self.bounds blendMode:kCGBlendModeDarken alpha:1];

img1 is a UIImage containing the mug image and img2 is another UIImage containing the overlay.

Also, check out the other blend modes supported by iOS. (kCGBlendModeDarken compares each pixel from img1 and img2 and selects the darkest one). For a much better explanation of blendmodes, then the one offered by apple, see http://en.wikipedia.org/wiki/Blend_modes

EsbenB
  • 3,356
  • 25
  • 44