views:

95

answers:

1

I am using the iPhone camera to capture an image and them resizing and adding a rounded corner. I'm having some users complain about crashes and I can't seem to find the problem. Also, the code runs very slow after selecting an image.

Can anyone offer suggestions to improve the method below?

-(void)imagePickerController:(UIImagePickerController *)imagePicker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
    [self dismissModalViewControllerAnimated:YES];

    CGSize newSize = CGSizeMake(500, 500);
    UIGraphicsBeginImageContext( newSize );
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSData *picAsPNG = UIImagePNGRepresentation(newImage);

    self.imageView.image = newImage;

    self.passedItem.itemImage = picAsPNG;
    self.eraseButton.hidden = NO;
    self.scrollImageButton.enabled = YES;
}
+1  A: 

Could it be a memory problem? I kwow UIImagePicker often causes memory warnings on older devices: are you releasing anything upon memory warning that you're assuming will be there later?

Amorya
That was mostly it, I think. I got ride of the resizing code and I can't get it to crash. I think I was just using too much memory.
Eric