Table of Contents

Class YuvPlane<TSample>

Namespace
Egami
Assembly
Egami.dll

One plane of a YuvRaster<TSample>: a width × height grid of raw samples, stored row by row. A row is always one contiguous span. Samples are stored low-bit aligned: a 10-bit sample is 0 to 1023 in a ushort.

public sealed class YuvPlane<TSample> where TSample : unmanaged

Type Parameters

TSample

The sample type: byte for 8 bits, ushort for 10 and 12 bits.

Inheritance
YuvPlane<TSample>
Inherited Members

Examples

using YuvRaster<byte> yuv = YuvRaster.Create(640, 480, ChromaFormat.Yuv420, YuvColor.Jpeg);

// Planes are read and written by row, like a raster's pixels.
for (int y = 0; y < yuv.Y.Height; y++)
{
    yuv.Y.Row(y).Fill((byte)(y / 2));
}

yuv.U!.Row(0)[0] = 128;

// An 8-bit plane can be viewed as Gray8 pixels, without copying.
PixelPlane<Gray8> luma = yuv.Y.AsGray8();

Remarks

Spans returned by Row(int) and TryGetContiguous(out Span<TSample>) point into the raster's memory. Do not keep them after the raster is disposed.

Properties

Height

Gets the height in samples.

public int Height { get; }

Property Value

int

Width

Gets the width in samples.

public int Width { get; }

Property Value

int

Methods

AsGray8()

Returns a view of an 8-bit plane as Gray8 pixels, without copying, so gray operations can read and write it. The view shares this plane's memory and is valid only as long as the raster.

public PixelPlane<Gray8> AsGray8()

Returns

PixelPlane<Gray8>

The view.

Exceptions

NotSupportedException

The samples are not 8-bit.

ObjectDisposedException

The raster has been disposed.

Row(int)

Returns one row of samples.

public Span<TSample> Row(int y)

Parameters

y int

The row index, 0 to Height - 1.

Returns

Span<TSample>

The row, exactly Width samples long.

Exceptions

ArgumentOutOfRangeException

y is outside the plane.

ObjectDisposedException

The raster has been disposed.

TryGetContiguous(out Span<TSample>)

Gets all samples as one span, if the plane is one block with no gap between rows.

public bool TryGetContiguous(out Span<TSample> samples)

Parameters

samples Span<TSample>

All Width × Height samples, row by row, or an empty span.

Returns

bool

true if the samples are contiguous.

Exceptions

ObjectDisposedException

The raster has been disposed.