2
我試圖使用屏幕截圖方法向場景中添加背景的模糊圖像 - 如簡述爲here和其他地方。在SpriteKit中添加模糊場景導致圖像大小問題
但是,在我的視網膜屏幕上,被覆蓋的圖像是1024 x 768而不是2048 x 1536.這使得它在屏幕上顯得非常小。如何通過調整此代碼覆蓋正確大小的圖像? ?
func blurWithCompletion() {
if let effectNode = scene?.childNode(withName: "effectsNode") as? SKEffectNode {
let blur = CIFilter(name: "CIGaussianBlur", withInputParameters: ["inputRadius": 10.0]);
effectNode.filter = blur;
effectNode.shouldRasterize = true;
effectNode.shouldEnableEffects = true;
UIGraphicsBeginImageContextWithOptions((view?.frame.size)!, true, 2.0)
view?.drawHierarchy(in: (view?.frame)!, afterScreenUpdates: true)
let image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
let node = SKSpriteNode(texture: SKTexture(image: image!));
effectNode.addChild(node);
}
}
編輯:圖.frame.size是1024×768;圖像大小是相同的。
編輯你的問題,並添加什麼看法.frame.size?!說。對'image'('image.size')做同樣的事情。還要改變這一行:'UIGraphicsBeginImageContextWithOptions((view?.frame.size)!,true,2.0)':to this:'UIGraphicsBeginImageContextWithOptions((view?.frame.size)!, true,0.0)' – Whirlwind
@Whirlwind Thanks,see above 。 – illuminatedtype
這是在您將scale參數設置爲0.0之前還是之後? – Whirlwind