aboutsummaryrefslogtreecommitdiff
path: root/Captura/Core Extensions/CVImageBuffer+cgImage.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Captura/Core Extensions/CVImageBuffer+cgImage.swift')
-rw-r--r--Captura/Core Extensions/CVImageBuffer+cgImage.swift5
1 files changed, 3 insertions, 2 deletions
diff --git a/Captura/Core Extensions/CVImageBuffer+cgImage.swift b/Captura/Core Extensions/CVImageBuffer+cgImage.swift
index c30cb0c..f8958f2 100644
--- a/Captura/Core Extensions/CVImageBuffer+cgImage.swift
+++ b/Captura/Core Extensions/CVImageBuffer+cgImage.swift
@@ -3,9 +3,10 @@ import ReplayKit
extension CVImageBuffer {
+ static let sharedContext = CIContext()
+
var cgImage: CGImage? {
let ciImage = CIImage(cvImageBuffer: self)
- let context = CIContext()
- return context.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: CVPixelBufferGetWidth(self), height: CVPixelBufferGetHeight(self)))
+ return CVImageBuffer.sharedContext.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: CVPixelBufferGetWidth(self), height: CVPixelBufferGetHeight(self)))
}
}