2

I want to merge multiple images into single image while saving to camera roll. Actually,I'm having different images in different views.I'm having 3 images in one view and also 4 images when selecting layout with 4 frames.someone help me how to merge them.

my sharing code:

 CGRect rect=[self.previewView bounds];
 UIGraphicsBeginImageContextWithOptions(rect.size, YES, 0.0f);
 CGSize size=CGSizeMake(self.previewView.frame.size.width, self.previewView.frame.size.height);
 if(selectButtonTag==2)
 {
 [self.doubleFrameViewcapturedImg1.image drawInRect:CGRectMake(0, 0, size.width, size.height)blendMode:kCGBlendModeNormal alpha:0.5];
 [self.doubleFrameViewcapturedImg2.image drawInRect:CGRectMake(0,0,size.width,size.height) blendMode:kCGBlendModeNormal alpha:0.5];
  }
 CGContextRef context=UIGraphicsGetCurrentContext();
 [self.previewView.layer renderInContext:context];
 UIImage *newImage=UIGraphicsGetImageFromCurrentImageContext();
 UIGraphicsEndImageContext();
 NSArray *activity=[[NSArray alloc]initWithObjects:UIActivityTypeCopyToPasteboard,
                   UIActivityTypeMail,
                   UIActivityTypeMessage,
                   UIActivityTypePostToFacebook,
                   UIActivityTypePostToTwitter,
                   UIActivityTypeSaveToCameraRoll,
                   UIActivityTypeAirDrop
                   , nil];
 UIActivityViewController *ShareView=[[UIActivityViewController alloc]initWithActivityItems:@[newImage,activity] applicationActivities:nil];
 ShareView.popoverPresentationController.sourceView=self.view;
 [self presentViewController:ShareView animated:YES completion:nil];

enter image description here

Huy Nghia
  • 996
  • 8
  • 22
App Developer
  • 419
  • 1
  • 3
  • 16
  • did you see [this](http://stackoverflow.com/questions/20878008/merge-multiple-images-into-one-image-in-iphone) or [this](http://stackoverflow.com/questions/18273271/merge-two-image-on-to-one-image-programmatically-in-iphone) ? – Huy Nghia Mar 09 '15 at 07:31
  • http://stackoverflow.com/questions/18273271/merge-two-image-on-to-one-image-programmatically-in-iphone ....this is what my app looks like but there will be 3 and also even 4 images – App Developer Mar 09 '15 at 07:33
  • so you could do same as that post with your app – Huy Nghia Mar 09 '15 at 07:35
  • i don't need to overlap them just the middle border should not be appeared and it should look like single image. – App Developer Mar 09 '15 at 08:06
  • i'll try and i'll say – App Developer Mar 09 '15 at 08:48
  • My issue was not solved @HuyNghia..see while sharing the image the 2 images or 3 images whatever the images are there,they should be viewed like single image(merged as single image).did u get me... – App Developer Mar 10 '15 at 04:36
  • please check that code ..by using tag value I'm getting views .if I select button tag =3 means,there will be 3 images .. – App Developer Mar 10 '15 at 04:43
  • did you check newImage exactly merge two image try display it – Huy Nghia Mar 10 '15 at 04:45
  • one more thing [self.doubleFrameViewcapturedImg1.image drawInRect:CGRectMake(0, 0, size.width, size.height)blendMode:kCGBlendModeNormal alpha:0.5]; [self.doubleFrameViewcapturedImg2.image drawInRect:CGRectMake(0,0,size.width,size.height) blendMode:kCGBlendModeNormal alpha:0.5]; frame in these lines not true. image 2 will be draw overlap image1 – Huy Nghia Mar 10 '15 at 04:49
  • yes.it will display as a single one but here in between both or 3 images there will be separated lines ,those lines should not be displayed and all images should be shared as a single image. – App Developer Mar 10 '15 at 04:49
  • I think this is not the correct way to show multiple images as single one... – App Developer Mar 10 '15 at 04:51
  • show your expect image look like ? I can't get you. – Huy Nghia Mar 10 '15 at 04:51
  • please check that image .it is having 2 separate images but converted to single image ..it should exactly look like this – App Developer Mar 10 '15 at 05:05
  • plz see discussion chat – Huy Nghia Mar 10 '15 at 05:21

1 Answers1

0

you can do this by using CoreGraphics,for more details just follow the tutorial by CodeTutePlus AdvancedImageTechnicsCoreGraphics

Ravi
  • 2,441
  • 1
  • 11
  • 30
  • Actually,I'm having different layouts of picking images like collage i need merge the images .did u get me like collage my view will be .if I select layout with 4 views those 4 images should be merged – App Developer Mar 09 '15 at 07:30