【发布时间】:2011-06-13 10:04:20
【问题描述】:
我目前正在制作一个 iphone 应用程序,用户可以在其中拍照或从相册中选择它,然后在图像上放置一个叠加层。然后用户可以缩放、旋转和保存图像。目前,我可以拍照,或者选择一张作为相册。至于叠加层,我只是使用了 UIImageView 并将其放置在 Interface builder 的层次结构之上。对于相机,我正在使用以下代码:
-(IBAction)getPhoto:(id)sender {
// Create an image picker controller
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
if((UIButton *) sender == choosePhotoBtn) {
// Set source to photo albums
imagePicker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
else {
// Set source to camera
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.showsCameraControls = YES;
}
// Delegate is self
imagePicker.delegate = self;
// Allow editing of image
imagePicker.allowsEditing = YES;
// Show image picker
[self presentModalViewController:imagePicker animated: YES];
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// Dismiss modalviewcontroller
[picker dismissModalViewControllerAnimated:YES];
// Displaying image to the imageView
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// Access the uncropped image from info dictionary
UIImage * image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// Save Image
UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
[picker release];
}
我现在遇到的问题是在拍摄后编辑照片。如何自定义相机以使其具有这样的行为?:
选择使用相机或从相册中获取照片
选择后,叠加图像将变为我在脸部放置“圆圈”的图像,照片将像面具一样位于下方。此视图还可以全屏编辑。您可以旋转、缩放和移动图像,直到单击完成。
我已阅读手册中的这一部分,但我似乎无法理解如何使用它。 http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
希望有人能指出正确的方向。
非常感谢。 -Hakimo
【问题讨论】:
标签: iphone ios uiimagepickercontroller