Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Swift OpenGL未解析标识符KCGIMAGEAlphaPremultipledLast_Ios_Swift_Opengl Es - Fatal编程技术网

Ios Swift OpenGL未解析标识符KCGIMAGEAlphaPremultipledLast

Ios Swift OpenGL未解析标识符KCGIMAGEAlphaPremultipledLast,ios,swift,opengl-es,Ios,Swift,Opengl Es,“KCGimageAlphaPremultipledLast”的标识符错误未解决。斯威夫特找不到它。这个有Swift吗 var gc = CGBitmapContextCreate(&pixelData, width: width, height: height, bitsPerComponent: 8, bytesPerRow: width*4, imageCS, bitmapInfo: kCGImageAlphaPremultipliedLast); 苹果的文档建议使用CGImag

“KCGimageAlphaPremultipledLast”的标识符错误未解决。斯威夫特找不到它。这个有Swift吗

var gc = CGBitmapContextCreate(&pixelData, width: width, height: height, bitsPerComponent: 8, bytesPerRow: width*4, imageCS, bitmapInfo: kCGImageAlphaPremultipliedLast);

苹果的文档建议使用
CGImageAlphaInfo.premultipledast


CGBitmapContextCreate()的最后一个参数定义为结构

struct CGBitmapInfo : RawOptionSetType {
    init(_ rawValue: UInt32)
    init(rawValue: UInt32)

    static var AlphaInfoMask: CGBitmapInfo { get }
    static var FloatComponents: CGBitmapInfo { get }
    // ...
}
其中,可能的“alpha-info”位单独定义为枚举:

enum CGImageAlphaInfo : UInt32 {
    case None /* For example, RGB. */
    case PremultipliedLast /* For example, premultiplied RGBA */
    case PremultipliedFirst /* For example, premultiplied ARGB */
    // ...
}
因此,必须将枚举转换为其基础
UInt32
值 然后从中创建
CGBitmapInfo

let bitmapInfo = CGBitmapInfo(CGImageAlphaInfo.PremultipliedLast.rawValue)
let gc = CGBitmapContextCreate(..., bitmapInfo)
Swift 2的更新:CGBitmapInfo的定义更改为

public struct CGBitmapInfo : OptionSetType
它可以用

let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.PremultipliedLast.rawValue)

谢谢你帮我节省了很多时间@马丁:太好了,谢谢你!