Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. if let croppedImage = self.cropImage2(image: UIImage(ciImage: image), rect: rect)?.cgImage {
  2.  
  3. let commandBuffer = self.commandQueue.makeCommandBuffer()!
  4.  
  5. let laplacian = MPSImageLaplacian(device: self.device)
  6.  
  7. let textureLoader = MTKTextureLoader(device: self.device)
  8.  
  9. let options: [MTKTextureLoader.Option : Any]? = nil
  10.  
  11. let srcTex = try! textureLoader.newTexture(cgImage: croppedImage, options: options)
  12.  
  13. let desc = MTLTextureDescriptor.texture2DDescriptor(pixelFormat: srcTex.pixelFormat, width: srcTex.width, height: srcTex.height, mipmapped: false)
  14.  
  15. let lapTex = self.device.makeTexture(descriptor: desc)
  16.  
  17. laplacian.encode(commandBuffer: commandBuffer, sourceTexture: srcTex, destinationTexture: lapTex!)
  18.  
  19. let output = CIImage(mtlTexture: lapTex!, options: [:])?.cgImage
  20.  
  21. print("output: (output?.width)")
  22.  
  23.  
  24. print("")
  25. }
  26.  
  27. let lapTex = self.device.makeTexture(descriptor: desc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement