質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,6 +14,66 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
+
以下は
|
18
|
+
|
19
|
+
class GameScene: SKScene{}
|
20
|
+
|
21
|
+
内のメソッド内のコードです。
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
```swift
|
26
|
+
|
27
|
+
class GameScene: SKScene{
|
28
|
+
|
29
|
+
func sample(){
|
30
|
+
|
31
|
+
/* 以下リンク先のコード引用 */
|
32
|
+
|
33
|
+
/* URL: https://sites.google.com/a/gclue.jp/swift-docs/ni-yinki100-ios/coreimage/hua-xiangnokuroppu */
|
34
|
+
|
35
|
+
let myInputImage = CIImage(image: UIImage(named: "image1.jpg")!)
|
36
|
+
|
37
|
+
let myImageView = UIImageView(frame: CGRectMake(0, 0, self.view!.frame.size.width, self.view!.frame.size.height))
|
38
|
+
|
39
|
+
myImageView.image = UIImage(CIImage: myInputImage!)
|
40
|
+
|
41
|
+
let myCropFilter = CIFilter(name: "CICrop")
|
42
|
+
|
43
|
+
myCropFilter!.setValue(myInputImage, forKey: kCIInputImageKey)
|
44
|
+
|
45
|
+
myCropFilter!.setValue(CIVector(x: 0, y: 300, z: 175, w: 300), forKey: "inputRectangle")
|
46
|
+
|
47
|
+
let myOutputImage : CIImage = myCropFilter!.outputImage!
|
48
|
+
|
49
|
+
myImageView.frame = CGRectMake(0, 0, 175, 300)
|
50
|
+
|
51
|
+
myImageView.image = UIImage(CIImage: myOutputImage)
|
52
|
+
|
53
|
+
//self.view!.addSubview(myImageView) //クリッピングされた画像が表示されるがやりたいことではない
|
54
|
+
|
55
|
+
/* 引用ここまで */
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
/* 以下やりたいこと */
|
60
|
+
|
61
|
+
let texture = SKTexture(image: UIImage(CIImage: myOutputImage))
|
62
|
+
|
63
|
+
let skSpriteNode = SKSpriteNode(texture: texture)
|
64
|
+
|
65
|
+
self.addChild(skSpriteNode) //何も表示されない
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
|
17
|
-
|
77
|
+
ご教授お願いします。
|
18
78
|
|
19
79
|
よろしくお願いします!
|