开发者

iPhone Choking on Certain Image Formats

开发者 https://www.devze.com 2023-01-14 14:18 出处:网络
My app allows upload of an image from the camera roll.Some images are causing the app to crash when I attempt to save them to my documents directory prior to upload.I\'m converting the image to a PNG

My app allows upload of an image from the camera roll. Some images are causing the app to crash when I attempt to save them to my documents directory prior to upload. I'm converting the image to a PNG prior to saving, but that hasn't helped. Here's the error...

Tue Aug 31 20:39:13 localhost XXX[76409] <Error>: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaLast; 1600 bytes/row.
Tue Aug 31 20:39:13 localhost XXX[76409] <Error>: CGContextConcatCTM: invalid context 0x0
Tue Aug 31 20:39:13 localhost XXX[76409] <Error>: CGContextSetInterpolationQuality: invalid context 0x0
Tue Aug 31 20:39:13 localhost XXX[76409] <Error>: CGContextDrawImage: invalid context 0x0
Tue Aug 31 20:39:13 localhost XXX[76409] <Error>: CGBitmapContextCreateImage: invalid context 0x0

and here's a sample of my code...

- (void)i开发者_JAVA技巧magePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

            UIImage *img =  [info objectForKey:@"UIImagePickerControllerOriginalImage"];

        NSData *pngData = UIImagePNGRepresentation(img);

        UIImage *pngImg = [UIImage imageWithData:pngData];

... code to save image ...

}


Note also that what you are doing is redundant and a waste of memory. img and pngImg are the same. Or is there a specific reason that you convert an image to png and then back to an image?

0

精彩评论

暂无评论...
验证码 换一张
取 消