回答編集履歴

1

記述もれ

2021/04/26 01:35

投稿

aaru
aaru

スコア1

test CHANGED
@@ -1,5 +1,45 @@
1
- ```ここに言語を入力
1
+ ```Swift
2
2
 
3
- コード
3
+ //合成
4
+
5
+ let si = UIImage.init(named: "org.jpg")
6
+
7
+ let mi = UIImage.init(named: "mask.jpg")
8
+
9
+ let bi = UIImage.init(named: "photo.jpg")
10
+
11
+
12
+
13
+ let sci = CIImage(image: si!)
14
+
15
+ let mci = CIImage(image: mi!)
16
+
17
+ let bci = CIImage(image: bi!)
18
+
19
+
20
+
21
+ let compositeImage = CIFilter(name: "CIBlendWithMask", parameters: [
22
+
23
+ kCIInputImageKey: sci,
24
+
25
+ kCIInputBackgroundImageKey:bci,
26
+
27
+ kCIInputMaskImageKey:mci])?.outputImage
28
+
29
+ self.displayView.image = UIImage(ciImage: compositeImage!)
30
+
31
+
32
+
33
+ //保存の為にUIImageへ変換
34
+
35
+ let context = CIContext()
36
+
37
+ let cgImage = context.createCGImage(compositeImage!,from: compositeImage!.extent)
38
+
39
+ let image2 = UIImage(cgImage: cgImage!)
40
+
41
+ self.displayView.image = image2
42
+
43
+
4
44
 
5
45
  ```