mam przepisywanie Apple UIImageEffects
przykładowy kod z Objective-C do Swift i mam pytanie dotyczące następującej linii:Łącząc CGBitmapInfo i CGImageAlphaInfo w Swift
vImage_CGImageFormat format = {
.bitsPerComponent = 8,
.bitsPerPixel = 32,
.colorSpace = NULL,
.bitmapInfo = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little,
.version = 0,
.decode = NULL,
.renderingIntent = kCGRenderingIntentDefault
};
Oto moja wersja 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)
Czy to najprostszy sposób utworzenia bitmapInfo
w Swift?
Nie ma operatora, ponieważ Swift chce, abyś pomyślał o nich jako o kolekcjach (więc operacje bitowe są rodzajem szczegółów implementacji). Preferowaną składnią jest użycie literału tablicowego: 'let bimapInfo: CGBitmapInfo = [CGBitmapInfo (rawValue: CGImageAlphaInfo.PremultipliedFirst.rawValue), .ByteOrder32Little]'. –