Showing
1 changed file
with
0 additions
and
25 deletions
| @@ -8,31 +8,6 @@ extension CVBuffer { | @@ -8,31 +8,6 @@ extension CVBuffer { | ||
| 8 | let cgImage = CIContext().createCGImage(ciImage, from: ciImage.extent) | 8 | let cgImage = CIContext().createCGImage(ciImage, from: ciImage.extent) |
| 9 | return UIImage(cgImage: cgImage!) | 9 | return UIImage(cgImage: cgImage!) |
| 10 | } | 10 | } |
| 11 | - | ||
| 12 | - var image1: UIImage { | ||
| 13 | - // Lock the base address of the pixel buffer | ||
| 14 | - CVPixelBufferLockBaseAddress(self, CVPixelBufferLockFlags.readOnly) | ||
| 15 | - // Get the number of bytes per row for the pixel buffer | ||
| 16 | - let baseAddress = CVPixelBufferGetBaseAddress(self) | ||
| 17 | - // Get the number of bytes per row for the pixel buffer | ||
| 18 | - let bytesPerRow = CVPixelBufferGetBytesPerRow(self) | ||
| 19 | - // Get the pixel buffer width and height | ||
| 20 | - let width = CVPixelBufferGetWidth(self) | ||
| 21 | - let height = CVPixelBufferGetHeight(self) | ||
| 22 | - // Create a device-dependent RGB color space | ||
| 23 | - let colorSpace = CGColorSpaceCreateDeviceRGB() | ||
| 24 | - // Create a bitmap graphics context with the sample buffer data | ||
| 25 | - var bitmapInfo = CGBitmapInfo.byteOrder32Little.rawValue | ||
| 26 | - bitmapInfo |= CGImageAlphaInfo.premultipliedFirst.rawValue & CGBitmapInfo.alphaInfoMask.rawValue | ||
| 27 | - //let bitmapInfo: UInt32 = CGBitmapInfo.alphaInfoMask.rawValue | ||
| 28 | - let context = CGContext(data: baseAddress, width: width, height: height, bitsPerComponent: 8, bytesPerRow: bytesPerRow, space: colorSpace, bitmapInfo: bitmapInfo) | ||
| 29 | - // Create a Quartz image from the pixel data in the bitmap graphics context | ||
| 30 | - let quartzImage = context?.makeImage() | ||
| 31 | - // Unlock the pixel buffer | ||
| 32 | - CVPixelBufferUnlockBaseAddress(self, CVPixelBufferLockFlags.readOnly) | ||
| 33 | - // Create an image object from the Quartz image | ||
| 34 | - return UIImage(cgImage: quartzImage!) | ||
| 35 | - } | ||
| 36 | } | 11 | } |
| 37 | 12 | ||
| 38 | extension UIDeviceOrientation { | 13 | extension UIDeviceOrientation { |
-
Please register or login to post a comment