Gorgon
Show / Hide Table of Contents

Class GorgonFormatInfo

Provides information for a specific DXGI Format.

Inheritance
object
GorgonFormatInfo
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Gorgon.Graphics
Assembly: Gorgon.Graphics.Imaging.dll
Syntax
public class GorgonFormatInfo
Remarks

This object will return the specifics for a DXGI Format, such as its bit depth, format grouping, and other information about the format. This is useful for determining how to handle a formatted element in a buffer at the byte level.

Constructors

| Edit this page View Source

GorgonFormatInfo(BufferFormat)

Initializes a new instance of the GorgonFormatInfo class.

Declaration
public GorgonFormatInfo(BufferFormat format)
Parameters
Type Name Description
BufferFormat format

The format to evaluate.

Remarks

If the format parameter is set to Unknown, then the members of this object, except for Group, will be set to default values and may not be accurate.

Fields

| Edit this page View Source

UnknownFormatInfo

A default information type for the Unknown format.

Declaration
public static readonly GorgonFormatInfo UnknownFormatInfo
Field Value
Type Description
GorgonFormatInfo

Properties

| Edit this page View Source

BitDepth

Property to return the bit depth for the format.

Declaration
public int BitDepth { get; }
Property Value
Type Description
int
Remarks

This is the number of bits in the format, not per component. For example, R8G8B8A8_UNorm would be 32 bits, and B5G6R5_UNorm would be 16 bits.

| Edit this page View Source

ComponentCount

Property to return the number of components for the format.

Declaration
public int ComponentCount { get; }
Property Value
Type Description
int
| Edit this page View Source

Format

Property to return the format that the information in this object is based on.

Declaration
public BufferFormat Format { get; }
Property Value
Type Description
BufferFormat
| Edit this page View Source

Group

Property to return the group for the format.

Declaration
public BufferFormat Group { get; }
Property Value
Type Description
BufferFormat
Remarks

The group for a format is typically its typeless counterpart. To be grouped with another format, the format must have the same byte ordering, and the format size must be the same as the other formats in the group.

For example, R8G8B8A8_UNorm would be a member of the group R8G8B8A8_Typeless, as would R8G8B8A8_SInt.

| Edit this page View Source

HasAlpha

Property to return whether the format has an alpha component.

Declaration
public bool HasAlpha { get; }
Property Value
Type Description
bool
| Edit this page View Source

HasDepth

Property to return whether the format has a depth component.

Declaration
public bool HasDepth { get; }
Property Value
Type Description
bool
Remarks

When this value returns true, then this format can be considered valid for use as a depth buffer format (this depends on available hardware support).

| Edit this page View Source

HasStencil

Property to return whether the format has a stencil component.

Declaration
public bool HasStencil { get; }
Property Value
Type Description
bool
Remarks

When this value returns true, then this format can be considered valid for use as a stencil buffer format (this depends on available hardware support).

| Edit this page View Source

IsCompressed

Property to return whether the pixel format is compressed or not.

Declaration
public bool IsCompressed { get; }
Property Value
Type Description
bool
Remarks

If this value returns true, then the format is meant for use with images that contain block compressed data.

| Edit this page View Source

IsPacked

Property to return whether the pixel format is packed or not.

Declaration
public bool IsPacked { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsPalettized

Property to return whether this format uses an indexed palette or not.

Declaration
public bool IsPalettized { get; }
Property Value
Type Description
bool
Remarks

For some 8 bit formats, the pixel value is an index into a larger palette of color values. For example, if the index 10 is mapped to a color value of R:64, G:32, B:128, then any pixels with the value of 10 will use that color from the palette.

| Edit this page View Source

IsSRgb

Property to return whether this format is an SRgb format or not.

Declaration
public bool IsSRgb { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsTypeless

Property to return whether the format is typeless or not.

Declaration
public bool IsTypeless { get; }
Property Value
Type Description
bool
Remarks

When this value returns true, then the components of the format may be interpreted in any way. If not, then the components of the format are expected to be interpreted as a known type.

| Edit this page View Source

SizeInBytes

Property to return the size of the format, in bytes.

Declaration
public int SizeInBytes { get; }
Property Value
Type Description
int

Methods

| Edit this page View Source

CalculateScanlines(int)

Function to compute the scan lines for a format, given a specific height.

Declaration
public int CalculateScanlines(int height)
Parameters
Type Name Description
int height

The height, in pixels.

Returns
Type Description
int

The number of scan lines.

Remarks

This will compute the number of scan lines for an image that uses the format that this information describes. If the format is IsCompressed, then this method will compute the scanline count based on the maximum size between 1 and a block size multiple of 4. If the format is not compressed, then it will just return the height value passed in.

| Edit this page View Source

GetPitchForFormat(int, int, PitchFlags)

Function to return pitch information for this format.

Declaration
public GorgonPitchLayout GetPitchForFormat(int width, int height, PitchFlags flags = PitchFlags.None)
Parameters
Type Name Description
int width

The width of the data.

int height

The height of the image pixel data.

PitchFlags flags

[Optional] Flags used to influence the row pitch.

Returns
Type Description
GorgonPitchLayout

The pitch information for the format.

Remarks

The flags parameter is used to compensate in cases where the original image data is not laid out correctly (such as with older DirectDraw DDS images).

Extension Methods

GorgonDebugExtensions.ValidateObject<T>(T, string)
GorgonNullExtensions.AsNullable<T>(object)
GorgonNullExtensions.IfNull<T>(object, T)
GorgonNullExtensions.IsNull(object)
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author