Function SRgba8.toAlphaSRgb

Converts packed RGBA bytes to normalized straight-alpha encoded sRGB.

Alpha!(SRgb!T) toAlphaSRgb(T)() const pure nothrow @nogc @safe
if (is(T == float) || is(T == double));

RGB and alpha bytes are divided independently by 255 in the requested scalar type. RGB remains straight and is not premultiplied by alpha, including when alpha is zero.

Returns

Straight Alpha!(SRgb!T) with every component in inclusive [0, 1].

Example

enum packed = SRgba8(255, 64, 0, 128);
enum normalized = packed.toAlphaSRgb!double();

static assert(normalized.color.r == 1.0);
static assert(normalized.color.g == 64.0 / 255.0);
static assert(normalized.color.b == 0.0);
static assert(normalized.alpha == 128.0 / 255.0);