IOS How to merge image
+ (UIImage*)mergeImage:(UIImage*)first withImage:(UIImage*)second atPoint:(CGPoint) point {
CGSize firstSize = first.size;
CGSize secondSize = second.size;
CGSize mergedSize = CGSizeMake(MAX(firstSize.width, secondSize.width),
MAX(firstSize.height, secondSize.height));
CGFloat mergedScale = MAX(first.scale, second.scale);
UIGraphicsBeginImageContextWithOptions(mergedSize, NO, mergedScale);
[first drawAtPoint:CGPointZero];
[second drawAtPoint:point];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
CGSize firstSize = first.size;
CGSize secondSize = second.size;
CGSize mergedSize = CGSizeMake(MAX(firstSize.width, secondSize.width),
MAX(firstSize.height, secondSize.height));
CGFloat mergedScale = MAX(first.scale, second.scale);
UIGraphicsBeginImageContextWithOptions(mergedSize, NO, mergedScale);
[first drawAtPoint:CGPointZero];
[second drawAtPoint:point];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Comments
Post a Comment