UIImageJPEGRepresentation 不返回原始图像。它将返回实际图像的压缩值。需要加载 NSData 中的原始图像数据集。有没有办法从图像中读取实际数据?
最佳答案
我认为您已尝试使用以下代码来使用 UIImageJPEGRepresentation
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
您可以像这样将图像转换为数据,反之亦然。
将 UIImage 转换为 NSData (png):
UIImage *image = [UIImage imageNamed:@"imageName.png"];
NSData *imageData = UIImagePNGRepresentation(image);
将 NSData 转换为 UIImage :
NSData *data = ... // data that you received
UIImage *image = [UIImage imageWithData:data];
关于ios - 需要在不压缩的情况下在 NSData 中加载 "original"图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40884916/