Table of Contents

Struct SampleComponent

Namespace
Egami.Formats
Assembly
Egami.dll

One component of a SampleImage.

[Experimental("EGAMIX001", UrlFormat = "https://github.com/inexin/Egami/blob/main/docs/articles/formats/index.md#stored-samples")]
public readonly record struct SampleComponent : IEquatable<SampleComponent>
Implements
Inherited Members

Examples

// The values the codestream stores: no color conversion, no widening to 8 or 16 bits, signed samples kept signed.
SampleImage image = SampleImage.Load("duck.jpg");
Console.WriteLine($"{image.Color}, {image.Components.Count} components of {image.Components[0].Precision} bits");

// A YCbCr JPEG stays YCbCr: luma, then the two chroma samples of each pixel, at full resolution.
Span<int> row = image.Row(0);
int luma = row[0], cb = row[1], cr = row[2];

Constructors

SampleComponent(int, bool)

One component of a SampleImage.

public SampleComponent(int Precision, bool IsSigned)

Parameters

Precision int

The bits per sample the codestream stores, 1 to 31.

IsSigned bool

Whether samples are signed: then they run from −2^(Precision − 1) to 2^(Precision − 1) − 1, else from 0 to 2^Precision − 1.

Examples

// The values the codestream stores: no color conversion, no widening to 8 or 16 bits, signed samples kept signed.
SampleImage image = SampleImage.Load("duck.jpg");
Console.WriteLine($"{image.Color}, {image.Components.Count} components of {image.Components[0].Precision} bits");

// A YCbCr JPEG stays YCbCr: luma, then the two chroma samples of each pixel, at full resolution.
Span<int> row = image.Row(0);
int luma = row[0], cb = row[1], cr = row[2];

Properties

IsSigned

Whether samples are signed: then they run from −2^(Precision − 1) to 2^(Precision − 1) − 1, else from 0 to 2^Precision − 1.

public bool IsSigned { get; init; }

Property Value

bool

Precision

The bits per sample the codestream stores, 1 to 31.

public int Precision { get; init; }

Property Value

int