问题
Given this image:
Is there a way to get a bezier path of the non-alpha parts from this image? Here, it would be the part delimited by the cat.
I know how to mask an image with another one:
func maskImage(image: UIImage, withMask maskImage: UIImage) -> UIImage {
let maskRef = maskImage.cgImage
let mask = CGImage(
maskWidth: maskRef!.width,
height: maskRef!.height,
bitsPerComponent: maskRef!.bitsPerComponent,
bitsPerPixel: maskRef!.bitsPerPixel,
bytesPerRow: maskRef!.bytesPerRow,
provider: maskRef!.dataProvider!,
decode: nil,
shouldInterpolate: false)
let masked = image.cgImage!.masking(mask!)
let maskedImage = UIImage(cgImage: masked!)
return maskedImage
}
But don't know how to get a bezier path from this.
Thanks for your help!
来源:https://stackoverflow.com/questions/49366374/how-to-get-a-bezier-path-from-a-uiimage-removing-its-alpha-parts