Image rotating after CIFilter

后端 未结 2 1365
生来不讨喜
生来不讨喜 2021-01-13 08:31

I\'m applying a CIFilter to a portrait image. For some reason, it gets rotated 90 clockwise. How can I fix this? My code is below

var imgOrientation = oImage         


        
2条回答
  •  一个人的身影
    2021-01-13 09:12

    You can try this :

    let cgImage = self.context.createCGImage(filterOutputImage,
                                             from: cameraImage.extent)!
    
    let orientation: UIImage.Orientation =
          currentCameraType == AVCaptureDevice.Position.front ?
               UIImage.Orientation.leftMirrored:
               UIImage.Orientation.right
    
    let image = UIImage(cgImage: cgImage,
                        scale: 1.0,
                        orientation: orientation)
    

提交回复
热议问题