Generic Instance Method

premultiplied(as:)

The color obtained by premultiplying the red, green, and blue components of this color with its alpha channel, performing the premultiplication in the given integer type.

Declaration

@inlinable func premultiplied<U>(as _:U.Type) -> Self where U:FixedWidthInteger & UnsignedInteger

Parameters

_

The integer type to perform the premultiplications in. U.bitWidth must be less than T.bitWidth.

Return value

The premultiplied color.

Overview

Premultiplication in a different integer type is sometimes necessary to reproduce the output of other image processing frameworks.

The premultiplied color is obtained by invoking premultiply(_:alpha:) on r, g, and b, after scaling them to the range of U. The returned components are then scaled back to the range of T. The rescaling operation also affects the a component.