GrayFloat Struct

An opaque grayscale pixel with a single-precision floating-point gray level, in 4 bytes per pixel.

public struct GrayFloat : IEquatable<GrayFloat>

Remarks

The gray level has the meaning of the colors of RgbaFloat: linear light where 1 is the reference white, with values outside [0, 1] allowed (highlights above 1). A new image of this pixel type is labeled as linear light (ColorTransferFunction.Linear), and the components are stored in native endianness.

Converting a color to it gives the Rec. 709 luma of the color, 0.2126 R + 0.7152 G + 0.0722 B (the luma of a gray color is that gray), and converting it to a color format repeats the gray level in the three colors. Converting it to an integer pixel format follows the rules of RgbaFloat.

Implements

Constructors

NameDescription
GrayFloat(float)Initializes a new instance of the GrayFloat struct.

GrayFloat(float)

GrayFloat.cs

Initializes a new instance of the GrayFloat struct.

public GrayFloat(float value)

Parameters

value float
The gray level.

Methods

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

GrayFloat.cs

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

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

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

Remarks

Values are compared with Single.Equals: a value that is not a number equals itself.

Equals(object?)

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

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

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

operator ==(GrayFloat, GrayFloat)

GrayFloat.cs

Compares two pixels for equality.

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

Parameters

left GrayFloat
The first pixel.
right GrayFloat
The second pixel.

Returns

bool true if the values are equal; otherwise false.

operator !=(GrayFloat, GrayFloat)

GrayFloat.cs

Compares two pixels for inequality.

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

Parameters

left GrayFloat
The first pixel.
right GrayFloat
The second pixel.

Returns

bool true if the values differ; otherwise false.

Fields

NameDescription
ValueThe gray level.

Value

The gray level.

public float Value