码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 图片合并 及截图

时间:2014-10-21 15:43:09      阅读:154      评论:0      收藏:0      [点我收藏+]

标签: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;
}

iOS 图片合并 及截图

标签:ios图片合并及截图

原文地址:http://liumenglin.blog.51cto.com/7734570/1566219

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!