iPhone 在某些图像格式上出现卡顿现象

发布于 2024-09-16 14:54:59 字数 1145 浏览 3 评论 0原文

我的应用程序允许从相机胶卷上传图像。当我尝试在上传之前将某些图像保存到我的文档目录中时,某些图像会导致应用程序崩溃。我在保存之前将图像转换为 PNG,但这没有帮助。这是错误...

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

这是我的代码示例...

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

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

        NSData *pngData = UIImagePNGRepresentation(img);

        UIImage *pngImg = [UIImage imageWithData:pngData];

... code to save image ...

}

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)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

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

        NSData *pngData = UIImagePNGRepresentation(img);

        UIImage *pngImg = [UIImage imageWithData:pngData];

... code to save image ...

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆沫 2024-09-23 14:54:59

另请注意,您所做的事情是多余的并且浪费内存。 imgpngImg 是相同的。或者是否有特定原因将图像转换为 png 然后再转换回图像?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文