Table of Contents

Struct PixelFormatDetails

Namespace
Sdl3Sharp.Video.Coloring
Assembly
Sdl3Sharp.dll

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>)

Gets a Color<byte> from an encoded pixel value

public void GetColor(uint pixelValue, Palette? palette, out Color<byte> color)

Parameters

pixelValue uint

An an encoded pixel value in the pixel format of this PixelFormatDetails

palette Palette

An optional Palette to use for indexed pixel formats

color Color<byte>

The Color<byte> 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 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

pixelValue uint

An an encoded pixel value in the pixel format of this PixelFormatDetails

palette Palette

An optional Palette to use for indexed pixel formats

r byte

The red component value of the encoded pixel value

g byte

The green component value of the encoded pixel value

b byte

The 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

pixelValue uint

An an encoded pixel value in the pixel format of this PixelFormatDetails

palette Palette

An optional Palette to use for indexed pixel formats

r byte

The red component value of the encoded pixel value

g byte

The green component value of the encoded pixel value

b byte

The blue component value of the encoded pixel value

a byte

The 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>)

Maps a Color<byte> to an encoded pixel value

public uint MapColor(Palette? palette, Color<byte> color)

Parameters

palette Palette

An optional Palette to use for indexed pixel formats

color Color<byte>

The Color<byte> to encoded

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

palette Palette

An optional Palette to use for indexed pixel formats

r byte

The red component value to encode

g byte

The green component value to encode

b byte

The 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

palette Palette

An optional Palette to use for indexed pixel formats

r byte

The red component value to encode

g byte

The green component value to encode

b byte

The blue component value to encode

a byte

The 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

formatProvider IFormatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in 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

format string

The format to use.

-or-

A null reference (Nothing in 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

format string

The format to use.

-or-

A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

formatProvider IFormatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in 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

destination Span<char>

The span in which to write this instance's value formatted as a span of characters.

charsWritten int

When this method returns, contains the number of characters that were written in destination.

format ReadOnlySpan<char>

A span containing the characters that represent a standard or custom format string that defines the acceptable format for destination.

provider IFormatProvider

An optional object that supplies culture-specific formatting information for destination.

Returns

bool

true if the formatting was successful; otherwise, false.