iOS 图片合并 及截图
两张图片合并
-(UIImage *)addImage:(UIImage *)image1 toImage:(UIImage *)image2
{
UIGraphicsBeginImageContext(image2.size);
//Draw image2
[image2 drawInRect:CGRectMake(0, 0, image2.size.width, image2.size.height)];
//Draw image1
[image1 drawInRect:CGRectMake(20, 20, image1.size.width, image1.size.height)];
UIImage *resultImage=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resultImage;
}
截图
- (UIImage*) combineImageFromCuttingScreen {
UIGraphicsBeginImageContext(self.baseImageView.frame.size);
UIGraphicsBeginImageContextWithOptions(self.combineView.frame.size, YES, 1);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetShouldAntialias(context, YES);
CGContextSetShouldSmoothFonts(UIGraphicsGetCurrentContext(),YES);
CGContextSaveGState(context);
CGRect r = CGRectMake(0, 0, 320, 392);
UIRectClip(r);
[self.combineView.layer renderInContext:context];
UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return theImage;
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。