Struct PixelFormatDetails
Represents details about a specific pixel format
public readonly struct PixelFormatDetails : ISpanFormattable, IFormattable
- Implements
- Inherited Members
Properties
ABits
Gets the number of bits used for the alpha component
public byte ABits { get; }
Property Value
- byte
The number of bits used for the alpha component
AMask
Gets a bit mask for the alpha component
public uint AMask { get; }
Property Value
- uint
A bit mask for the alpha component
AShift
Gets the shift value for the alpha component
public byte AShift { get; }
Property Value
- byte
The shift value for the alpha component
BBits
Gets the number of bits used for the blue component
public byte BBits { get; }
Property Value
- byte
The number of bits used for the blue component
BMask
Gets a bit mask for the blue component
public uint BMask { get; }
Property Value
- uint
A bit mask for the blue component
BShift
Gets the shift value for the blue component
public byte BShift { get; }
Property Value
- byte
The shift value for the blue component
BitsPerPixel
Gets the number of bits per pixel
public byte BitsPerPixel { get; }
Property Value
- byte
The number of bits per pixel
BytesPerPixel
Gets the number of bytes per pixel
public byte BytesPerPixel { get; }
Property Value
- byte
The number of bytes per pixel
Format
Gets the pixel format this PixelFormatDetails describes
public PixelFormat Format { get; }
Property Value
- PixelFormat
The pixel format this PixelFormatDetails describes
GBits
Gets the number of bits used for the green component
public byte GBits { get; }
Property Value
- byte
The number of bits used for the green component
GMask
Gets a bit mask for the green component
public uint GMask { get; }
Property Value
- uint
A bit mask for the green component
GShift
Gets the shift value for the green component
public byte GShift { get; }
Property Value
- byte
The shift value for the green component
RBits
Gets the number of bits used for the red component
public byte RBits { get; }
Property Value
- byte
The number of bits used for the red component
RMask
Gets a bit mask for the red component
public uint RMask { get; }
Property Value
- uint
A bit mask for the red component
RShift
Gets the shift value for the red component
public byte RShift { get; }
Property Value
- byte
The shift value for the red component
Methods
GetColor(uint, Palette?, out Color<byte>)
public void GetColor(uint pixelValue, Palette? palette, out Color<byte> color)
Parameters
pixelValueuintAn an encoded pixel value in the pixel format of this PixelFormatDetails
palettePaletteAn optional Palette to use for indexed pixel formats
colorColor<byte>
Remarks
This method uses the entire 8-bit (0-255) range when converting color components from pixel formats with less than 8-bits per RGB component
(e.g., a completely white pixel in 16-bit Rgb565 format would return (R, G, B) = (0xff, 0xff, 0xff),
not (0xf8, 0xfc, 0xf8)).
If the surface has no alpha component, the A value will be returned as 0xff (fully opaque).
GetColor(uint, Palette?, out byte, out byte, out byte)
Gets the RGB component values from an encoded pixel value
public void GetColor(uint pixelValue, Palette? palette, out byte r, out byte g, out byte b)
Parameters
pixelValueuintAn an encoded pixel value in the pixel format of this PixelFormatDetails
palettePaletteAn optional Palette to use for indexed pixel formats
rbyteThe red component value of the encoded pixel value
gbyteThe green component value of the encoded pixel value
bbyteThe blue component value of the encoded pixel value
Remarks
This method uses the entire 8-bit (0-255) range when converting color components from pixel formats with less than 8-bits per RGB component
(e.g., a completely white pixel in 16-bit Rgb565 format would return (r, g, b) = (0xff, 0xff, 0xff),
not (0xf8, 0xfc, 0xf8)).
GetColor(uint, Palette?, out byte, out byte, out byte, out byte)
Gets the RGBA component values from an encoded pixel value
public void GetColor(uint pixelValue, Palette? palette, out byte r, out byte g, out byte b, out byte a)
Parameters
pixelValueuintAn an encoded pixel value in the pixel format of this PixelFormatDetails
palettePaletteAn optional Palette to use for indexed pixel formats
rbyteThe red component value of the encoded pixel value
gbyteThe green component value of the encoded pixel value
bbyteThe blue component value of the encoded pixel value
abyteThe alpha component value of the encoded pixel value
Remarks
This method uses the entire 8-bit (0-255) range when converting color components from pixel formats with less than 8-bits per RGB component
(e.g., a completely white pixel in 16-bit Rgb565 format would return (r, g, b) = (0xff, 0xff, 0xff),
not (0xf8, 0xfc, 0xf8)).
If the surface has no alpha component, the alpha component value will be returned as 0xff (fully opaque).
MapColor(Palette?, Color<byte>)
public uint MapColor(Palette? palette, Color<byte> color)
Parameters
Returns
- uint
An encoded pixel value in the pixel format of this PixelFormatDetails
Remarks
This method maps the Color<byte> to the specified pixel format and returns the encoded pixel value best approximating the given Color<byte> for the pixel format.
If the pixel format is indexed and uses a Palette the index of the closest matching color in the palette will be returned.
If the pixel format has no alpha component, the given alpha component value will be ignored (as it will be in indexed formats with a Palette).
If the pixel format's bits-per-pixel value (color depth) is less than 32-bits per pixel then the unused upper bits of the returned encoded pixel value can safely be ignored (e.g., with a 16-bits per pixel format the returned encoded pixel value can be safely cast (truncated) to an ushort value, and similarly to a byte value for an 8-bits per pixel formats).
MapColor(Palette?, byte, byte, byte)
Maps RGB component values to an opaque encoded pixel value
public uint MapColor(Palette? palette, byte r, byte g, byte b)
Parameters
palettePaletteAn optional Palette to use for indexed pixel formats
rbyteThe red component value to encode
gbyteThe green component value to encode
bbyteThe blue component value to encode
Returns
- uint
An encoded pixel value in the pixel format of this PixelFormatDetails
Remarks
This method maps the RGB color value to the specified pixel format and returns the encoded pixel value best approximating the given RGB color value for the pixel format.
If the pixel format is indexed and uses a Palette the index of the closest matching color in the palette will be returned.
If the pixel format has an alpha component, the encoded pixel value's alpha component value will be set to be fully opaque.
If the pixel format's bits-per-pixel value (color depth) is less than 32-bits per pixel then the unused upper bits of the returned encoded pixel value can safely be ignored (e.g., with a 16-bits per pixel format the returned encoded pixel value can be safely cast (truncated) to an ushort value, and similarly to a byte value for an 8-bits per pixel formats).
MapColor(Palette?, byte, byte, byte, byte)
Maps RGBA component values to an encoded pixel value
public uint MapColor(Palette? palette, byte r, byte g, byte b, byte a)
Parameters
palettePaletteAn optional Palette to use for indexed pixel formats
rbyteThe red component value to encode
gbyteThe green component value to encode
bbyteThe blue component value to encode
abyteThe alpha component value to encode
Returns
- uint
An encoded pixel value in the pixel format of this PixelFormatDetails
Remarks
This method maps the RGBA color value to the specified pixel format and returns the encoded pixel value best approximating the given RGBA color value for the pixel format.
If the pixel format is indexed and uses a Palette the index of the closest matching color in the palette will be returned.
If the pixel format has no alpha component, the given alpha component value will be ignored (as it will be in indexed formats with a Palette).
If the pixel format's bits-per-pixel value (color depth) is less than 32-bits per pixel then the unused upper bits of the returned encoded pixel value can safely be ignored (e.g., with a 16-bits per pixel format the returned encoded pixel value can be safely cast (truncated) to an ushort value, and similarly to a byte value for an 8-bits per pixel formats).
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
ToString(IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(IFormatProvider? formatProvider)
Parameters
formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
ToString(string?)
Formats the value of the current instance using the specified format.
public string ToString(string? format)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.
Returns
- string
The value of the current instance in the specified format.
ToString(string?, IFormatProvider?)
Formats the value of the current instance using the specified format.
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.
Returns
- string
The value of the current instance in the specified format.
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Tries to format the value of the current instance into the provided span of characters.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)
Parameters
destinationSpan<char>The span in which to write this instance's value formatted as a span of characters.
charsWrittenintWhen this method returns, contains the number of characters that were written in
destination.formatReadOnlySpan<char>A span containing the characters that represent a standard or custom format string that defines the acceptable format for
destination.providerIFormatProviderAn optional object that supplies culture-specific formatting information for
destination.