Gorgon
Show / Hide Table of Contents

Struct GorgonPitchLayout

Information about the pitch layout for buffer data.

Implements
IEquatable<GorgonPitchLayout>
Inherited Members
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetType()
Namespace: Gorgon.Graphics.Imaging
Assembly: Gorgon.Graphics.Imaging.dll
Syntax
public readonly struct GorgonPitchLayout : IEquatable<GorgonPitchLayout>
Remarks

The pitch layout indicates how data is organized within in a buffer. For most buffer types, this is simply the size of the buffer from 0 to n - 1. But for other buffer types, such as images then extra dimensions are used to define the layout of the data.

In a 2D image, there is a width and a height. Or for a depth (3D) image, there is a width, height and depth. The number of bytes between each dimension must be used to determine where to start reading/writing data in the memory occupied by the image.

In many cases, the "width" of an image is not necessarily the number of pixels across, it may also include extra padding information for alignment purposes. This information is returned in the RowPitch for the pitch layout. This value is typically the number of pixels * bytes per pixel + padding bytes. Like a 2D image, a depth (3D) image must use this information to determine where to start reading/writing data in the memory occupied by the image.

For depth (3D) images, there is a slice value. This indicates the total size of one element along the Z-axis and typically represents the bytes in the width * height of the image. The SlicePitch returns the total size of a single slice. The slice is calculated by bytes in the width * height * slice index (z element)). For a 2D image, this value represents just a single slice (i.e. bytes in the width * height).

Constructors

| Edit this page View Source

GorgonPitchLayout(int, int, int, int)

Initializes a new instance of the GorgonPitchLayout struct.

Declaration
public GorgonPitchLayout(int rowPitch, int slicePitch, int horizontalBlockCount = 0, int verticalBlockCount = 0)
Parameters
Type Name Description
int rowPitch

The number of bytes for a row in an image, or the total bytes for other buffer types.

int slicePitch

The number of bytes between each slice in a depth (3D) image, or, for other image types, this indicates the total size of the image in bytes.

int horizontalBlockCount

[Optional] The number of horizontal blocks in a block compressed format.

int verticalBlockCount

[Optional] The number of vertical blocks in a block compressed format.

Remarks

For a 2D image, the slicePitch indicates the total size of the image, in bytes (typically rowPitch * height). In a depth image (3D), this indicates the size, in bytes, of a single slice along the Z-axis of the image. For other buffer types, this will be the same as the rowPitch parameter.

If the format is a block compressed image (e.g. BC3_UNorm), then both the horizontalBlockCount, and the verticalBlockCount must be larger than 0. Otherwise an exception will be thrown.

Exceptions
Type Condition
ArgumentEmptyException

Thrown when the horizontalBlockCount is greater than 0, and the verticalBlockCount is 0, or the verticalBlockCount is greater than 0, and the horizontalBlockCount is 0.

Fields

| Edit this page View Source

HorizontalBlockCount

The number of horizontal blocks in a compressed format.

Declaration
public readonly int HorizontalBlockCount
Field Value
Type Description
int
Remarks

In the block compressed formats (e.g. BC3_UNorm), the dimensions of the images are broken up into 4x4 blocks. This value indicates the total number of 4x4 blocks across the width of the image. For example, if an image has a width of 256 pixels, it would be 64 blocks in the horizontal direction.

| Edit this page View Source

RowPitch

The number of bytes per line of data.

Declaration
public readonly int RowPitch
Field Value
Type Description
int
Remarks

In an image, this indicates the number of bytes necessary for one row of pixel data, for other buffer types, this would indicate the size of the buffer, in bytes.

| Edit this page View Source

SlicePitch

The number of bytes per slice of data.

Declaration
public readonly int SlicePitch
Field Value
Type Description
int
Remarks

For a 2D image, this value indicates the total size of the image, in bytes (typically RowPitch * height). In a depth image (3D), this indicates the size, in bytes, of a single slice along the Z-axis of the image. For other buffer types, this will be the same as the RowPitch value.

| Edit this page View Source

VerticalBlockCount

The number of vertical blocks in a compressed format.

Declaration
public readonly int VerticalBlockCount
Field Value
Type Description
int
Remarks

In the block compressed formats (e.g. BC3_UNorm), the dimensions of the images are broken up into 4x4 blocks. This value indicates the total number of 4x4 blocks across the height of the image. For example, if an image has a height of 256 pixels, it would be 64 blocks in the vertical direction.

Methods

| Edit this page View Source

Equals(GorgonPitchLayout)

Function to compare two instances for equality.

Declaration
public bool Equals(GorgonPitchLayout other)
Parameters
Type Name Description
GorgonPitchLayout other

The other instance to compare to this one.

Returns
Type Description
bool

true if equal, false if not.

| Edit this page View Source

Equals(GorgonPitchLayout, GorgonPitchLayout)

Function to compare two instances for equality.

Declaration
public static bool Equals(GorgonPitchLayout left, GorgonPitchLayout right)
Parameters
Type Name Description
GorgonPitchLayout left

Left instance to compare.

GorgonPitchLayout right

Right instance to compare.

Returns
Type Description
bool

true if equal, false if not.

| Edit this page View Source

Equals(object)

Determines whether the specified object is equal to this instance.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

The object to compare with this instance.

Returns
Type Description
bool

true if the specified object is equal to this instance; otherwise, false.

Overrides
ValueType.Equals(object)
| Edit this page View Source

GetHashCode()

Returns a hash code for this instance.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Overrides
ValueType.GetHashCode()
| Edit this page View Source

ToString()

Returns a string that represents this instance.

Declaration
public override string ToString()
Returns
Type Description
string

A string that represents this instance.

Overrides
ValueType.ToString()

Operators

| Edit this page View Source

operator ==(GorgonPitchLayout, GorgonPitchLayout)

Equality operator.

Declaration
public static bool operator ==(GorgonPitchLayout left, GorgonPitchLayout right)
Parameters
Type Name Description
GorgonPitchLayout left

The left instance to compare.

GorgonPitchLayout right

The right instance to compare.

Returns
Type Description
bool

true if equal, false if not

| Edit this page View Source

operator !=(GorgonPitchLayout, GorgonPitchLayout)

Inequality operator.

Declaration
public static bool operator !=(GorgonPitchLayout left, GorgonPitchLayout right)
Parameters
Type Name Description
GorgonPitchLayout left

The left instance to compare.

GorgonPitchLayout right

The right instance to compare.

Returns
Type Description
bool

true if not equal, false if they are.

Implements

IEquatable<T>

Extension Methods

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