简体   繁体   中英

Can you use a grayscale image with no alpha as a layer mask?

Normally if you install an image as the contents of a layer's mask layer, the alpha channel of the mask layer's image is what masks the other layer. I know how to do that.

I have a vague memory of reading that you can instead install a grayscale image with no alpha and use the brightness of the image as the mask. I've tried searching various ways, but can't find any documentation about that.

Am I imagining it?

It would be more memory efficient, and make your code cleaner, if you could draw into a mask image using a shade of gray.

For CALayer , the mask is alpha mask. In CoreGraphics, one can mask with grayscale image . Also, Core Image has CIMaskToAlpha filter which one can use to convert grayscale image to alpha mask.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM