2016-07-30 5 views

答えて

2

NSImageNSAttributedStringを描画する方法は次のとおりです。でも、私は(最後の行)をCIImageへの変換をテストしていないが、それはあまりにも難しいことではありません。

let string = NSAttributedString(string: "Hello World!", attributes: [NSFontAttributeName: NSFont.labelFontOfSize(10)]) 
let image = NSImage(size: string.size()) 
image.lockFocus() 
NSGraphicsContext.saveGraphicsState() 
NSGraphicsContext.currentContext()!.shouldAntialias = true 
string.drawAtPoint(NSZeroPoint) 
NSGraphicsContext.restoreGraphicsState() 
image.unlockFocus() 

let ciimage = CIImage(data: image.TIFFRepresentation!)! 
+0

ありがとうございました!それがトリックでした。また、CIImageへの変換は正常に機能し、私のカスタムCIFilterは問題なく処理しました。 – Optimalist

関連する問題