I'm currently making an iphone app where the user takes a photo or select it from an album, then an overlay is placed over the image. The user can then scale, rotate and save the image. Currently, I can take pictures, or choose one for the album. As for the overlay, I just used UIImageView and placed it on top of the hierarchy in Interface builder. For the camera, I'm using this code:
-(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];
}
The problem I'm having right now, is editing the photo after it's being taken. How do I customise the camera to behave like this?:
Choose either use the camera or getting the photo from the album
Once chosen, the overlay image will change to a one where I've put a "circle" in the face, and the photo will be underneath like a mask. This view will also be able to edit in full screen. You can rotate, scale and move the image until you click done.
I've read this part in the manual but I can't seem to understand how to use it. http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html
Hope someone can point me to the right direction.
Thanks very much. -Hakimo
there's a way don't change your code much:
If you want to use the image that after editing, please change "UIImagePickerControllerOriginalImage" to "UIImagePickerControllerEditedImage", that's it!
For Q1, is it possible to implement an action sheet, so that the user can choose to use the photo from an album or take a new pic.? with the action sheet function as something like the following: