Rgba1010102 Struct

A pixel with 10-bit red, green and blue components and a 2-bit straight (non-premultiplied) alpha, packed in a 32-bit value.

public struct Rgba1010102 : IEquatable<Rgba1010102>

Remarks

Rgba1010102.PackedValue is stored in native endianness and holds red in its 10 low bits, then green, then blue, and alpha in its 2 high bits: the layout of DXGI_FORMAT_R10G10B10A2_UNORM and of the RGBA_1010102 bitmaps of Android. The colors go from 0 to 1023 and the alpha from 0 (fully transparent) to 3 (fully opaque).

A component is the fraction of its largest value: conversions to and from the other formats round to the nearest sample, so the conversion to a format with 16 bits per component and back is exact, and a conversion to this format reduces the precision (alpha keeps 4 levels).

Implements

Constructors

NameDescription
Rgba1010102(ushort, ushort, ushort, byte)Initializes a new instance of the Rgba1010102 struct.

Rgba1010102(ushort, ushort, ushort, byte)

Rgba1010102.cs

Initializes a new instance of the Rgba1010102 struct.

public Rgba1010102(ushort r, ushort g, ushort b, byte a = 3)

Parameters

r ushort
The red component, from 0 to 1023.
g ushort
The green component, from 0 to 1023.
b ushort
The blue component, from 0 to 1023.
a byte
The straight alpha component, from 0 to 3. Defaults to fully opaque.

Exceptions

ArgumentOutOfRangeException
A component is larger than the largest value of its bits.

Properties

NameDescription
AGets or sets the straight alpha component, from 0 (fully transparent) to 3 (fully opaque).
BGets or sets the blue component, from 0 to 1023.
GGets or sets the green component, from 0 to 1023.
RGets or sets the red component, from 0 to 1023.

Gets or sets the straight alpha component, from 0 (fully transparent) to 3 (fully opaque).

public byte A { readonly get; set; }

Property value

byte

Exceptions

ArgumentOutOfRangeException
The value is larger than 3.

Gets or sets the blue component, from 0 to 1023.

public ushort B { readonly get; set; }

Property value

ushort

Exceptions

ArgumentOutOfRangeException
The value is larger than 1023.

Gets or sets the green component, from 0 to 1023.

public ushort G { readonly get; set; }

Property value

ushort

Exceptions

ArgumentOutOfRangeException
The value is larger than 1023.

Gets or sets the red component, from 0 to 1023.

public ushort R { readonly get; set; }

Property value

ushort

Exceptions

ArgumentOutOfRangeException
The value is larger than 1023.

Methods

NameDescription
Equals(Rgba1010102)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Indicates whether this instance and a specified object are equal.
GetHashCode()Returns the hash code for this instance.
ToString()Returns the fully qualified type name of this instance.

Equals overloads

Equals(Rgba1010102)

Rgba1010102.cs

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(Rgba1010102 other)
Parameters
other Rgba1010102
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Rgba1010102.cs

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current instance.
Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Rgba1010102.cs

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int A 32-bit signed integer that is the hash code for this instance.

ToString()

Rgba1010102.cs

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string The fully qualified type name.

Operators

NameDescription
operator ==(Rgba1010102, Rgba1010102)Compares two pixels for equality.
operator !=(Rgba1010102, Rgba1010102)Compares two pixels for inequality.

operator ==(Rgba1010102, Rgba1010102)

Rgba1010102.cs

Compares two pixels for equality.

public static bool operator ==(Rgba1010102 left, Rgba1010102 right)

Parameters

left Rgba1010102
The first pixel.
right Rgba1010102
The second pixel.

Returns

bool true if all components are equal; otherwise false.

operator !=(Rgba1010102, Rgba1010102)

Rgba1010102.cs

Compares two pixels for inequality.

public static bool operator !=(Rgba1010102 left, Rgba1010102 right)

Parameters

left Rgba1010102
The first pixel.
right Rgba1010102
The second pixel.

Returns

bool true if any component differs; otherwise false.

Fields

NameDescription
PackedValueThe packed components: red in bits 0 to 9, green in bits 10 to 19, blue in bits 20 to 29 and alpha in bits 30 and 31.

PackedValue

The packed components: red in bits 0 to 9, green in bits 10 to 19, blue in bits 20 to 29 and alpha in bits 30 and 31.

public uint PackedValue