どのようにRGB画像をグレースケール色空間に変換できますか?私は... MacOSのためのiOS版が、非のためのコードの多くを見つけることができるとAppleのドキュメンテーションはスイフト3色空間macOS IOS
let width = image.size.width
let height = image.size.height
let imageRect = NSMakeRect(0, 0, width, height);
let colorSpace = CGColorSpaceCreateDeviceGray();
let bits = image.representations.first as! NSBitmapImageRep;
bitmap!.representationUsingType(NSBitmapImageFileType.NSPNGFileType, properties: nil)
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue);
let context = CGContext(data: nil, width: Int(width), height: Int(height), bitsPerComponent: 8, bytesPerRow: 0, space: colorSpace, bitmapInfo: bitmapInfo.rawValue);
context.draw(image.cgImage!, in : imageRect);// and this line is wrong obviously..
これは私がそうfar..justからコピー&ペースト持っているものです....すべての客観Cでありますインターネットは..しかし、私はさらに進んで行く方法については考えていません。
[NSImageの色空間を変更する](http://stackoverflow.com/questions/3253521/changing-the-color-space-of-nsimage/42042573#42042573)色を変更する方法を教えてくださいスペース。私は最終的なマスキングステップに入っています。 – user3390652
私が適切な方法でそれをやろうと努力しているのは、Appleのフレームワークが色空間を定義していることがわかったからです。私は他の色空間の将来の設定について心配する必要はありません:) – user3390652