How to get a bezier path from a UIImage removing its alpha parts?

倾然丶 夕夏残阳落幕 提交于 2019-12-11 04:33:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!