有什么方法可以在不将 CIImage 转换为 UIImage 或 CGImage 的情况下将 CIImage 转换为 NSData?

Is there any way to convert CIImage to NSData without converting CIImage to UIImage or CGImage?

有什么方法可以将CIImage转换为NSData而不将CIImage转换为UIImageCGImage

我正在尝试制作一个相机应用程序。 抓图时,我用CIImage处理图片,给图片加滤镜效果,编辑一些元数据,用PHAssetCreationRequest保存。

在这个过程中,我将imagedata 更改为CIImage,CIImage 更改为UIImage,UIImage 更改为NSData。显然这需要时间,我想节省一些时间。

So, Is there any way to convert CIImage to NSData without converting CIImage to UIImage or CGImage?

CIContext 有一个方法,JPEGRepresentationOfImage:colorSpace:options,可以在不转换为 UIImage 的情况下转换为 NSData。

CIContext *contextToUse = ...;
NSData *imageData = [contextToUse JPEGRepresentationOfImage:image colorSpace:... options:@{}];