Table of Contents

Class YuvRaster<TSample>

Namespace
Egami
Assembly
Egami.dll

A picture held as separate Y, U, V and optional alpha planes of TSample samples. See YuvRaster.

public sealed class YuvRaster<TSample> : YuvRaster, IDisposable where TSample : unmanaged

Type Parameters

TSample

byte for 8 bits, ushort for 10, 12 and 16 bits.

Inheritance
YuvRaster<TSample>
Implements
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();

Properties

A

Gets the alpha plane, full size, straight and always full range, or null without alpha.

public YuvPlane<TSample>? A { get; }

Property Value

YuvPlane<TSample>

HasAlpha

Gets a value indicating whether the raster has an alpha plane.

public override bool HasAlpha { get; }

Property Value

bool

U

Gets the U (Cb, blue difference) plane, or null for 4:0:0. It is half the luma width, rounded up, for 4:2:0 and 4:2:2, and half the luma height, rounded up, for 4:2:0; a quarter of the luma width, rounded up, for 4:1:1 and 4:1:0, and a quarter of the luma height, rounded up, for 4:1:0.

public YuvPlane<TSample>? U { get; }

Property Value

YuvPlane<TSample>

V

Gets the V (Cr, red difference) plane, the same size as U, or null for 4:0:0.

public YuvPlane<TSample>? V { get; }

Property Value

YuvPlane<TSample>

Y

Gets the luma plane, Width × Height.

public YuvPlane<TSample> Y { get; }

Property Value

YuvPlane<TSample>

Methods

Crop(Rect)

Returns a new raster holding rect of this one. See Crop(Rect).

public YuvRaster<TSample> Crop(Rect rect)

Parameters

rect Rect

The area to keep, in luma pixels.

Returns

YuvRaster<TSample>

The new raster. The caller must dispose it.

Exceptions

ArgumentOutOfRangeException

The rectangle is empty or reaches outside the raster.

ArgumentException

The rectangle's corner is not on a chroma sample.

ObjectDisposedException

The raster has been disposed.

Resize(int, int, ResampleFilter)

Returns a new raster with every plane resized. See Resize(int, int, ResampleFilter).

public YuvRaster<TSample> Resize(int width, int height, ResampleFilter filter = ResampleFilter.Bicubic)

Parameters

width int

The new luma width, at least 1.

height int

The new luma height, at least 1.

filter ResampleFilter

The resampling kernel. Defaults to Bicubic.

Returns

YuvRaster<TSample>

The new raster. The caller must dispose it.

Exceptions

ArgumentOutOfRangeException

A size is less than 1.

LimitExceededException

The new raster breaks the context's SafetyLimits.

ObjectDisposedException

The raster has been disposed.