kCGImageAlphaNone unresolved identifier in swift

扶醉桌前 提交于 2019-12-01 06:39:18

You have to create a struct CGBitmapInfo from the CGImageAlphaInfo.None value:

let bitmapInfo = CGBitmapInfo(CGImageAlphaInfo.None.rawValue)
var context = CGBitmapContextCreate(nil, UInt(width), UInt(height), 8, 0, colorSpace, bitmapInfo)

I believe the original Objective-C code was wrong. The kCGImageAlphaNone enum value was not the appropriate type to be passing, but Objective-C is less type safe (an enum is an enum) so it worked. The raw value of kCGImageAlphaNone is 0, so passing CGBitmapInfo.allZeros or CGBitmapInfo.ByteOrderDefault (both of which have raw values of 0) should give you the same results.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!