如何在iOS中将UIImage转换为J2K(JPEG2000)?
我已经设法让OpenJPEG在我的iOS应用程序中编译,但我不知道从哪里开始尝试将UIImage转换为J2K文件或J2K内存缓冲区。 build议?
显然ImageIO可以做到这一点。 你需要添加图像io框架到你的项目,然后这个代码为我工作:
#import <ImageIO/ImageIO.h> // or @import ImageIO if modules enabled #import <MobileCoreServices/MobileCoreServices.h> // ... // quality is 0-1 (0 = smallest file size, 1 = lossless quality) + (NSData*) convertToJPEG2000:(UIImage*)image withQuality:(float)quality { NSMutableData* d = [NSMutableData data]; CGImageDestinationRef destinationRef = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)d, kUTTypeJPEG2000, 1, NULL); CGImageDestinationSetProperties(destinationRef, NULL); CGImageDestinationAddImage(destinationRef, image.CGImage, (__bridge CFDictionaryRef)@{ (NSString*)kCGImageDestinationLossyCompressionQuality: @(quality) }); if (!CGImageDestinationFinalize(destinationRef)) { d = nil; } CFRelease(destinationRef); return d; }
- CFHTTPMessageAddAuthentication无法向请求添加身份validation数据
- 查看分辨率中心通信历史记录的任何选项 – iTunes Connect
- 转发地理编码不会给出正确的结果
- 苹果增强现实的下一步:ARKit 1.5更新
- 正确的方法为UIAlertView添加声音
- MergeSwiftModule – 在Xcode 6.3中构建一个Swift应用程序卡在“Merge MyApp.swiftmodule”中
- 如何在UIWebview中的目录(JS,图像,CSS)加载本地HTML资产? (IOS)
- Objective C ePub框架
- 你如何处理“要求(…,保释)”与ARC的声明?