我希望将多个图像合并为单张图像,同时保存到相机胶卷。 实际上,我在不同的视图中有不同的图像。我在一个视图中有3个图像,在选择4个帧的布局时也有4个图像。有人帮我如何合并它们。
我的分享代码:
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];
答案 0 :(得分:0)
您可以使用CoreGraphics
执行此操作,有关详细信息,请按照CodeTutePlus AdvancedImageTechnicsCoreGraphics