Thursday, December 16, 2010

blend two uiimages

blend two uiimages
 
 
 
UIImage* bottomImage = [UIImage imageNamed:@"bottom.png"];  UIImage* topImage    = [UIImageNamed:@"top.png"];
UIImageView* imageView = [[UIImageView alloc] initWithImage:bottomImage];
UIImageView* subView   = [[UIImageView alloc] initWithImage:topImage];
subView.alpha = 0.5;  // Customize the opacity of the top image.
[imageView addSubview:subView];
UIGraphicsBeginImageContext(imageView.frame.size);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[subView release];
[imageView release];
[self doWhateverIWantWith: blendedImage];
 
 
 
 
 
 
 

iPhone : warning: no ‘-renderInContext:’ method found – solution

There is a simple solution to this pesky warning:
  1. Add the following to your .h file :
    #import <QuartzCore/QuartzCore.h>
  2. You may also need to add  “CoreGraphics.framework” to your project, if its not already there.
 

No comments:

Post a Comment