1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
- (UIImage *) photoMerge:(UIImage*)leftImage1 :(UIImage*)rightImage1 :(UIImage*)leftImage2 :(UIImage*)rightImage2 { CGFloat width = 1000;//最终合并后图片 宽度 CGFloat height = 1000;//最终合并后图片 高度
CGSize offScreenSize = CGSizeMake(width, height); UIGraphicsBeginImageContext(offScreenSize);
//左上 CGRect rect = CGRectMake(0, 0, width/2, height/2); [leftImage1 drawInRect:rect];
//右上 rect.origin.x += width/2; [rightImage1 drawInRect:rect];
//左下 CGRect rect2 = CGRectMake(0, height/2, width/2, height/2); [leftImage2 drawInRect:rect2];
//右下 rect2.origin.x += width/2; [rightImage2 drawInRect:rect2];
UIImage* imagez = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return imagez; }
|
近期评论