Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using UIImagepickerController cameraoverlayview to take picture?

i am using UIImagepickerController to take pictures from camera..i am using my own view over the camera view by using the cameraoverlayview property...i want to take a picture from camera when user clicks on a button in my custom view...i am using the following code

 - (void)viewDidLoad {

imagePickerController = [[UIImagePickerController alloc] init];
    imagePickerController.sourceType =  UIImagePickerControllerSourceTypeCamera;
    [self presentModalViewController:imagePickerController animated:YES];   
    imagePickerController.showsCameraControls=NO;

imagePickerController.cameraOverlayView = self.customView;

}

- (IBAction) takePicture
{
    [imagePickerController takePicture];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];

    imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];

[picker dismissModalViewControllerAnimated:YES];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissModalViewControllerAnimated:YES];
}

but when i run this code it gives me error

ERROR: FigCreateCGImageFromJPEG returned -12905. Input (null) was 773625 bytes.

and i also get warnings for memory use level 2 and then level 1

and no image is displayed in the imageView.. can anyone help me what i might be doing wrong?? btw i am using iPhone 3G with iOS4.1 installed on it

like image 203
hemant Avatar asked Jan 29 '26 13:01

hemant


1 Answers

UIImagePickerControllerOriginalImage is a symbol (an NSString * constant) and you can't assume its value. Use as is, without quotes. Other than that, if you properly retain and create both the picker and the image view, it should work.

like image 177
djromero Avatar answered Jan 31 '26 05:01

djromero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!