0

I'm trying to merge two images in one, and save that image onto the camera roll. But it just show a blank image. Can anyone help?

My code:

-(void)SaveFinalImage{    
    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *savedImg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(savedImg, nil, nil, nil);     
}
Michael Petrotta
  • 58,479
  • 27
  • 141
  • 176
rihurla
  • 363
  • 2
  • 15

1 Answers1

3

I have used this in my app.

UIImage *bottomImage = [UIImage imageNamed:@"bottom.png"]; //background image
UIImage *image       = [UIImage imageNamed:@"top.png"]; //foreground image

CGSize newSize = CGSizeMake(width, height);
UIGraphicsBeginImageContext( newSize );

// Use existing opacity as is
[bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];

// Apply supplied opacity if applicable
[image drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:0.8];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

for more see my related answer on the same subject. iOS - Merging two images of different size

Community
  • 1
  • 1
Srikar Appalaraju
  • 69,116
  • 53
  • 210
  • 260