我希望我的用户能够将一些图像上传到一个小方块中,然后我想将所有这些图像保存到用户iPhone上的一个图像中。
我基本上制作了一个应用程序,将用户图片彼此相结合(那里有很多类似的应用程序,但我想了解它们是如何工作的),然后将整个事物保存为图像在他们的电话上。
答案 0 :(得分:0)
将所有图像保存在数组(arrImage)中,并使用以下方法合并图像
- (UIImage *) mergeImages:(NSArray*)arrImage{
float width = 2024;//set the width of merged image
float height = 2024;//set the height of merged image
CGSize mergedImageSize = CGSizeMake(width, height);
float x = 0;
float y= 0;
UIGraphicsBeginImageContext(mergedImageSize);
for(UIImage *img in arrImages){
CGRect rect = CGRectMake(x, y, width/arrimage.count, height/arrImage.count);
[img drawInRect:rect];
x=x+(width/arrimage.count);
y=y+(height/arrImage.count))
}
UIImage* mergedImage = UIGraphicsGetImageFromCurrentImageContext();// it will return an image based on the contents of the current bitmap-based graphics context.
UIGraphicsEndImageContext();
return mergedImage;
}