iphone – 使用ImageIO在iOS上创建渐进式jpeg在设备上产生块状结果

iphone – 使用ImageIO在iOS上创建渐进式jpeg在设备上产生块状结果,第1张

概述我正在尝试从UI Image对象创建一个渐进的jpeg,这是我的代码 NSMutableData *data = [NSMutableData data];NSString *path = [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Caches/test.jpg"];CFURLRef url = CFURLCr 我正在尝试从UI Image对象创建一个渐进的jpeg,这是我的代码

NSMutableData *data = [NSMutableData data];Nsstring *path = [NSHomeDirectory() stringByAppendingPathComponent: @"library/Caches/test.jpg"];CFURLRef url = CFURLCreateWithString(NulL,(CFStringRef)[Nsstring stringWithFormat:@"file://%@",path],NulL);CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url,kUTTypeJPEG,1,NulL);CFRelease(url);NSDictionary *jfifPropertIEs = [NSDictionary dictionaryWithObjectsAndKeys:                                (__brIDge ID)kcfBooleanTrue,kCGImagePropertyJFIFIsProgressive,nil];NSDictionary *propertIEs = [NSDictionary dictionaryWithObjectsAndKeys:                            [NSNumber numberWithfloat:.7],kCGImageDestinationLossyCompressionQuality,jfifPropertIEs,kCGImagePropertyJFIFDictionary,nil];CGImageDestinationAddImage(destination,((UIImage*)object).CGImage,(__brIDge CFDictionaryRef)propertIEs);CGImageDestinationFinalize(destination);CFRelease(destination);@H_301_12@  

这在模拟器运行时非常好,但不幸的是在设备上产生了块状或块状的结果:

关于发生什么的任何想法?我会恢复使用UIImageJPEGRepresentation作为最后的手段,我真的需要渐进的JPEG.

解决方法 好消息:我刚刚在iPhone 4上测试过,图像看起来很棒:

NSDictionary *jfifPropertIEs = [NSDictionary dictionaryWithObjectsAndKeys:@72,kCGImagePropertyJFIFXDensity,@72,kCGImagePropertyJFIFYDensity,@1,kCGImagePropertyJFIFDensityUnit,nil];@H_301_12@  

(使用新的文字语法).

这些密度选项意味着什么好的JFIF reference.

总结

以上是内存溢出为你收集整理的iphone – 使用ImageIO在iOS上创建渐进式jpeg在设备上产生块状结果全部内容,希望文章能够帮你解决iphone – 使用ImageIO在iOS上创建渐进式jpeg在设备上产生块状结果所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1019379.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存