
vImage_CGImageFormat format = { .bitsPerComponent = 8,.bitsPerPixel = 32,.colorSpace = NulL,.bitmAPInfo = kCGImageAlphaPremultiplIEdFirst | kCGBitmapByteOrder32little,.version = 0,.decode = NulL,.renderingIntent = kCGRenderingIntentDefault}; 这是我在Swift中的版本:
let bitmAPInfo = CGBitmAPInfo(rawValue: CGImageAlphaInfo.PremultiplIEdFirst.rawValue | CGBitmAPInfo.ByteOrder32little.rawValue)let format = vImage_CGImageFormat(bitsPerComponent: 8,bitsPerPixel: 32,colorSpace: nil,bitmAPInfo: bitmAPInfo,version: 0,decode: nil,renderingIntent: .RenderingIntentDefault)
这是在Swift中创建bitmAPInfo的最简单方法吗?
解决方法 你可以让它变得更简单:let bimAPInfo = CGBitmAPInfo(rawValue: CGImageAlphaInfo.PremultiplIEdFirst.rawValue) .union(.ByteOrder32little)
遗憾的是,您无法将CGImageAlphaInfo转换为CGBitmAPInfo.这只是当前API的一个弱点.但是一旦你拥有它,你可以使用.union将它与其他值结合起来.一旦枚举类型已知,您就不必继续重复它.
我觉得这里没有运算符,这很奇怪.我为此开了一个雷达,包括一个|实现. http://www.openradar.me/23516367
public func |<T: SetAlgebraType>(lhs: T,rhs: T) -> T { return lhs.union(rhs)}@warn_unused_resultpublic func |=<T : SetAlgebraType>(inout lhs: T,rhs: T) { lhs.unionInPlace(rhs)}let bimAPInfo = CGBitmAPInfo(rawValue: CGImageAlphaInfo.PremultiplIEdFirst.rawValue) | .ByteOrder32little 总结 以上是内存溢出为你收集整理的ios – 在Swift中组合CGBitmapInfo和CGImageAlphaInfo全部内容,希望文章能够帮你解决ios – 在Swift中组合CGBitmapInfo和CGImageAlphaInfo所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)