How to create your own mask in ios

enter image description here

Duplicate

so do not deny my reputation.

Image of my mask: enter image description here

My conclusion: enter image description here

- (UIImage*)maskImage:(UIImage *)image withMask:(UIImage *)maskImage { CGImageRef maskRef = maskImage.CGImage; CGImageRef mask = CGImageMaskCreate( CGImageGetWidth(maskRef), CGImageGetHeight(maskRef), CGImageGetBitsPerComponent(maskRef), CGImageGetBitsPerPixel(maskRef), CGImageGetBytesPerRow(maskRef), CGImageGetDataProvider(maskRef), NULL, false ); CGImageRef masked = CGImageCreateWithMask(image.CGImage, mask); CGImageRelease(mask); return [UIImage imageWithCGImage:masked]; } 

So how to create your own mask image?

Thanks...

+7
source share
1 answer

Try converting the image to a halftone image without alpha.

  • Save it as .jpg to remove alpha. Then you can save it back to png. This image should work already.

  • Convert it to shades of gray (since color information is discarded in this type of masking) using image-> mode-> greyscale.

enter image description here

+5
source

All Articles