【发布时间】:2019-02-24 13:59:31
【问题描述】:
我正在尝试在 Swift 中创建一个 IOSurface,然后从中创建一个 CIImage。 IOSurfaceRef 看起来不错,但 CIImage 返回 nil:
textureImageWidth = 1024
textureImageHeight = 1024
let macPixelFormatString = "ARGB"
var macPixelFormat: UInt32 = 0
for c in macPixelFormatString.utf8 {
macPixelFormat *= 256
macPixelFormat += UInt32(c)
}
let ioSurface = IOSurfaceCreate([kIOSurfaceWidth: textureImageWidth,
kIOSurfaceHeight: textureImageHeight,
kIOSurfaceBytesPerElement: 4,
kIOSurfaceBytesPerRow: textureImageWidth * 4,
kIOSurfaceAllocSize: textureImageWidth * textureImageHeight * 4,
kIOSurfacePixelFormat: macPixelFormat] as CFDictionary)!
IOSurfaceLock(ioSurface, IOSurfaceLockOptions.readOnly, nil)
let test = CIImage(ioSurface: ioSurface)
IOSurfaceUnlock(ioSurface, IOSurfaceLockOptions.readOnly, nil)
有什么建议吗?我猜 CIImage 初始化程序需要更多元数据来完成它的工作,但我不知道是什么。
【问题讨论】:
标签: ios swift core-image ciimage iosurface