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
- 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
Width
Gets the width in samples.
public int Width { get; }
Property Value
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
Returns
Exceptions
- ArgumentOutOfRangeException
yis 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
Returns
Exceptions
- ObjectDisposedException
The raster has been disposed.