【发布时间】:2017-12-07 23:35:15
【问题描述】:
我有一个由 CVPixelbuffer (ARGB) 构成的 CGImage。我想将该 CGImage 转换为 MTLTexture。我用:
let texture: MTLTexture = try m_textureLoader.newTexture(with: cgImage, options: [MTKTextureLoaderOptionSRGB : NSNumber(value: true)] )
稍后我想在具有 3 个通道的 MPSImage 中使用纹理:
let sid = MPSImageDescriptor(channelFormat: MPSImageFeatureChannelFormat.float16, width: 40, height: 40, featureChannels: 3)
preImage = MPSTemporaryImage(commandBuffer: commandBuffer, imageDescriptor: sid)
lanczos.encode(commandBuffer: commandBuffer, sourceTexture: texture!, destinationTexture: preImage.texture)
scale.encode (commandBuffer: commandBuffer, sourceImage: preImage, destinationImage: srcImage)
现在我的问题: textureLoader.newTexture(...) 如何将四个 ARGB 通道映射到 MPSImageDescriptor 中指定的 3 个通道? 如何确保使用 RGB 组件而不是例如精氨酸? 有没有办法指定通道映射?
谢谢,克里斯
【问题讨论】:
标签: swift metal cgimage metalkit