如何从UIImagePickerController和cameraoverlay视图合并捕获的照片? 然后我想把它保存到相册。
需要帮助。
答案 0 :(得分:3)
我会创建一个图像上下文,然后将两个图像写入其中。然后使用UIImageWriteToSavedPhotosAlbum保存到相册。这是一个示例,当我从按钮调用时,我在保存的图像上放置了一个徽标。在您的情况下,品牌形象将是您的叠加层,imageToSave将是来自UIImagePickerController的图像。修改以适应。希望它会有所帮助:
- (IBAction)saveImage:(id)sender{
//add brand to image
UIImage *BrandImage = [UIImage imageNamed:@"brand.png"];
UIImage* imageToSave = [imageView image]; //get current imageView
CGSize targetSize = CGSizeMake(self.imageView.image.size.width, self.imageView.image.size.height);
CGRect imageRect = CGRectMake(0, 0, self.imageView.image.size.width, self.imageView.image.size.height);
//get screen size for retina or non retina
UIScreen *MainScreen = [UIScreen mainScreen];
UIScreenMode *ScreenMode = [MainScreen currentMode];
CGSize Size = [ScreenMode size];
//position brand logo according to screen size
if (Size.width == 640) {
topImageRect = CGRectMake(self.imageView.image.size.width - 160, self.imageView.image.size.height - 80, 141, 53);
}
else
{
topImageRect = CGRectMake(self.imageView.image.size.width - 80, self.imageView.image.size.height - 40, 71, 27);
}
UIGraphicsBeginImageContext(targetSize);
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
[imageToSave drawInRect:imageRect];
[BrandImage drawInRect:topImageRect];
UIGraphicsPopContext();
// get a UIImage from the image context
UIImage* SavedImage = UIGraphicsGetImageFromCurrentImageContext();
// clean up drawing environment
UIGraphicsEndImageContext();
// Save it to the camera roll / saved photo album
UIImageWriteToSavedPhotosAlbum(SavedImage, nil, nil, nil);
}
答案 1 :(得分:0)
我认为这可能有助于使用相机叠加视图并将叠加的点击图像保存到库http://red-glasses.com/index.php/tutorials/ios4-take-photos-with-live-video-preview-using-avfoundation/
答案 2 :(得分:0)
抱歉,我之前没有收到您的问题。一种方法是以编程方式捕获屏幕截图,然后根据您的要求编辑图像并保存。
这应该有帮助...... How to take a screenshot programmatically