作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将从图像选择器中提取的图像保存到 mysql 数据库中,我检索图像并尝试使用它创建一个 uiimage
[self.currentPicView setImage:[[UIImage alloc] initWithData:[[Person person] current_pic]]];
它给了我错误:
<Error>: ImageIO: PNG [5C][30][0D]I: invalid chunk type
<Error>: ImageIO: PNG [5C][30][0D]I: invalid chunk type
没有崩溃..图像只是不显示。我不知道该错误是什么意思或如何解决它。有什么想法吗?
附言:
[[Person person] current_pic]
包含 PNG 图像数据。Person 是一个单例。 current_pic 是 Person 中的一个 NSData 属性。我不能包含该代码,因为属性是合成的,所以我没有自己创建方法或覆盖它。
为了准备和上传(通过 POST 使用来自 here 的 EPUpload)图像,我这样做:
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image= [info objectForKey:@"UIImagePickerControllerOriginalImage"];
NSData *webData = UIImagePNGRepresentation(image);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:@"temp-file"];
[webData writeToFile:localFilePath atomically:YES];
NSLog(@"localFilePath.%@",localFilePath);
[self doUpload:localFilePath];
[[picker parentViewController] dismissViewControllerAnimated:YES completion:^{}];
}
更新:当我使用“webData”在 didFinishPickingMedia 方法中构造一个 UIImage 时,它没有给出错误,并且图像创建时没有错误。
我尝试使用 POST 将相同的 webData 直接上传到服务器,然后检索它并尝试从中创建另一个图像,但再次出现错误
最佳答案
当我的 bundle 中有两个同名的 png 图像时,我遇到了这个问题! orange.png
和 orange.png
...将第二个重命名为 citrus.png
,我什至没有意识到它们有相同的名字至少一个小时,每当我尝试加载该图像时,应用程序都会因此错误而崩溃。
关于ios - <Error> : ImageIO: PNG [5C][30][0D]I: invalid chunk type mean? 是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23900947/
我是一名优秀的程序员,十分优秀!