The following code gives me a photo in portrait mode irrespective of the orientation. How do I ensure the photo respects the current orientation?
-(void) TakePhotoWithCamera
{
[self startCameraPickerFromViewController:self usingDelegate:self];
}
- (BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject
{
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsImageEditing = YES;
picker.delegate = self;
[controller presentModalViewController:picker animated:YES];
[picker release];
}
return YES;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage * img = [info objectForKey:@"UIImagePickerControllerEditedImage"];
[self useImage:img];
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
}
-(void)useImage:(UIImage *)theImage {
NSData *addImageData = UIImagePNGRepresentation(theImage);
// Here we return the Image
}
My aplication is in portrait mode. if I select the image from gallery or with camera , I am getting the image like Tiles with above coding.