iOS 图像处理 - 图像拼接

解决这个问题:将两个图像拼接在一起

前提:须要加入Framework:CoreGraphics.framework

源代码:

- (UIImage *) combine:(UIImage*)leftImage :(UIImage*)rightImage {
    CGFloat width = leftImage.size.width * 2;
    CGFloat height = leftImage.size.height;
    CGSize offScreenSize = CGSizeMake(width, height);
    
    UIGraphicsBeginImageContext(offScreenSize);
    
    CGRect rect = CGRectMake(0, 0, width/2, height);
    [leftImage drawInRect:rect];
    
    rect.origin.x += width/2;
    [rightImage drawInRect:rect];
    
    UIImage* imagez = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return imagez;
}

參考:网上资源。链接已丢失

posted @ 2017-07-01 13:36  wzzkaifa  阅读(898)  评论(0编辑  收藏  举报