Cropping CIImage with CICrop isn't working properly

后端 未结 3 2006
说谎
说谎 2020-12-24 03:16

I\'m having troubles cropping image. For me CICrop filter is not working properly. If my CIVector x and y (origins) are 0 everything working fine (image is cropped from left

3条回答
  •  佛祖请我去吃肉
    2020-12-24 04:08

    This is how CICrop works -- it crop the rect you specified, and the un-cropped area becomes transparent. If you print extent you will see that it is still the same original rect.

    As suggested, you can do a translation. This is now just 1 line, in Swift 5:

    let newImage = myCIImage.transformed(by: CGAffineTransform(translationX: -150, y: -150)
    

提交回复
热议问题