我有一個 CIFilter 管道。
它目前UIImage使用以下輸出:
private func renderImage(ciImage: CIImage) -> UIImage?
{
let cgImage = Filter.context.createCGImage(ciImage, from: ciImage.extent)
return cgImage.map(UIImage.init)
}
這UIImage是后來轉換為JPEG和存盤。
現在需要批量過濾影像并跳過UIImage格式。這需要盡快完成。
這里有幾種方法可以做到這一點。
哪種方式最快?
uj5u.com熱心網友回復:
你也可以這樣做CIContext:
let colorSpace = CGColorSpace(name: CGColorSpace.sRGB)!
// if you need the JPEG data
let data = Filter.context.jpegRepresentation(of: ciImage, colorSpace: colorSpace)
// or if you want to write to file directly
try Filter.context.writeJPEGRepresentation(of: ciImage, to: url, colorSpace: colorSpace)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/360319.html
