This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// Remove background of input image based on an alpha mask. | |
| /// | |
| /// - Parameters: | |
| /// - image: Image to mask | |
| /// - mask: Input mask. Reduces pixel opacity by mask alpha value. For instance | |
| /// an alpha value of 255 will be completely opaque, 0 will be completely transparent | |
| /// and a value of 125 will be partially transparent. | |
| /// - Returns: Image mask with background removed. | |
| func createMask(of image: UIImage, fromMask mask: UIImage, withBackground background: UIImage? = nil) -> UIImage? { | |
| guard let imageCG = image.cgImage, let maskCG = mask.cgImage else { return nil } |