Instance Method


Creates a bitmap image by masking an existing bitmap image with the provided color values.


func copy(maskingColorComponents components: [CGFloat]) -> CGImage?



An array of color components that specify a color or range of colors to mask the image with. The array must contain 2N values { min[1], max[1], ... min[N], max[N] } where N is the number of components in color space of image. Each value in components must be a valid image sample value. If image has integer pixel components, then each value must be in the range [0 .. 2**bitsPerComponent - 1] (where bitsPerComponent is the number of bits/component of image). If image has floating-point pixel components, then each value may be any floating-point number which is a valid color component.

Return Value

An image created by masking image with the colors specified in the components array. You are responsible for releasing this object by calling CGImageRelease.


Any image sample with color value {c[1], ... c[N]} where min[i] <= c[i] <= max[i] for 1 <= i <= N is masked out (that is, not painted). This means that anything underneath the unpainted samples, such as the current fill color, shows through.

See Also

Creating Images by Modifying an Image

func cropping(to: CGRect) -> CGImage?

Creates a bitmap image using the data contained within a subregion of an existing bitmap image.

func masking(CGImage) -> CGImage?

Creates a bitmap image from an existing image and an image mask.