Bgr565 Struct

An opaque pixel with a 5-bit red, a 6-bit green and a 5-bit blue component, packed in a 16-bit value.

public struct Bgr565 : IEquatable<Bgr565>

Remarks

Bgr565.PackedValue is stored in native endianness and holds blue in its 5 low bits, green in the next 6 bits and red in its 5 high bits: the layout of DXGI_FORMAT_B5G6R5_UNORM and of the RGB_565 bitmaps of Android. The components go from 0 to 31 (red and blue) or 63 (green), the largest value of their bits.

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 8 bits or more per component and back is exact, and a conversion to this format reduces the precision.

Implements

Constructors

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

Bgr565(byte, byte, byte)

Bgr565.cs

Initializes a new instance of the Bgr565 struct.

public Bgr565(byte r, byte g, byte b)

Parameters

r byte
The red component, from 0 to 31.
g byte
The green component, from 0 to 63.
b byte
The blue component, from 0 to 31.

Exceptions

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

Properties

NameDescription
BGets or sets the blue component, from 0 to 31.
GGets or sets the green component, from 0 to 63.
RGets or sets the red component, from 0 to 31.

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

public byte B { readonly get; set; }

Property value

byte

Exceptions

ArgumentOutOfRangeException
The value is larger than 31.

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

public byte G { readonly get; set; }

Property value

byte

Exceptions

ArgumentOutOfRangeException
The value is larger than 63.

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

public byte R { readonly get; set; }

Property value

byte

Exceptions

ArgumentOutOfRangeException
The value is larger than 31.

Methods

NameDescription
Equals(Bgr565)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(Bgr565)

Bgr565.cs

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

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

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

Equals(object?)

Bgr565.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()

Bgr565.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()

Bgr565.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 ==(Bgr565, Bgr565)Compares two pixels for equality.
operator !=(Bgr565, Bgr565)Compares two pixels for inequality.

operator ==(Bgr565, Bgr565)

Bgr565.cs

Compares two pixels for equality.

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

Parameters

left Bgr565
The first pixel.
right Bgr565
The second pixel.

Returns

bool true if all components are equal; otherwise false.

operator !=(Bgr565, Bgr565)

Bgr565.cs

Compares two pixels for inequality.

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

Parameters

left Bgr565
The first pixel.
right Bgr565
The second pixel.

Returns

bool true if any component differs; otherwise false.

Fields

NameDescription
PackedValueThe packed components: blue in bits 0 to 4, green in bits 5 to 10 and red in bits 11 to 15.

PackedValue

The packed components: blue in bits 0 to 4, green in bits 5 to 10 and red in bits 11 to 15.

public ushort PackedValue