【问题标题】:iPhone Choking on Certain Image FormatsiPhone 在某些图像格式上窒息
【发布时间】:2010-09-01 02:46:54
【问题描述】:

我的应用允许从相机胶卷上传图像。当我尝试在上传之前将它们保存到我的文档目录时,某些图像会导致应用程序崩溃。我在保存之前将图像转换为 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 ...

}

【问题讨论】:

  • 您应该提供崩溃发生附近的代码。你得到的错误只是说你使用了一个无效的上下文来操作你的图像。

标签: iphone quartz-graphics


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-29
    • 1970-01-01
    • 2013-10-25
    • 2012-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多