Table of Contents

Class JpegComponent

Namespace
Egami.Formats.Jpeg
Assembly
Egami.dll

One component of a JPEG frame and its sampling factors.

public sealed record JpegComponent : IEquatable<JpegComponent>
Inheritance
JpegComponent
Implements
Inherited Members

Examples

using Raster photo = Raster.Load("duck.jpg", options: new JpegReaderOptions { FastUpsampling = true });
JpegDetails details = (JpegDetails)photo.Metadata.FormatDetails!;
Console.WriteLine($"{details.ColorSpace}, progressive: {details.Progressive}, quality about {details.EstimatedQuality}");
foreach (JpegComponent component in details.Components)
{
    Console.WriteLine($"Component {component.Id}: sampled {component.HorizontalSampling} × {component.VerticalSampling}");
}

// Gray output, and 4:4:4 (no chroma subsampling) for sharp colored edges.
photo.Save("gray.jpg", new JpegWriterOptions { ColorType = JpegColorType.Gray });
photo.Save("sharp.jpg", new JpegWriterOptions { Quality = 90, Subsampling = ChromaSubsampling.Subsample444 });

Constructors

JpegComponent(int, int, int)

One component of a JPEG frame and its sampling factors.

public JpegComponent(int Id, int HorizontalSampling, int VerticalSampling)

Parameters

Id int

The component identifier from the frame header.

HorizontalSampling int

The horizontal sampling factor, 1 to 4.

VerticalSampling int

The vertical sampling factor, 1 to 4.

Examples

using Raster photo = Raster.Load("duck.jpg", options: new JpegReaderOptions { FastUpsampling = true });
JpegDetails details = (JpegDetails)photo.Metadata.FormatDetails!;
Console.WriteLine($"{details.ColorSpace}, progressive: {details.Progressive}, quality about {details.EstimatedQuality}");
foreach (JpegComponent component in details.Components)
{
    Console.WriteLine($"Component {component.Id}: sampled {component.HorizontalSampling} × {component.VerticalSampling}");
}

// Gray output, and 4:4:4 (no chroma subsampling) for sharp colored edges.
photo.Save("gray.jpg", new JpegWriterOptions { ColorType = JpegColorType.Gray });
photo.Save("sharp.jpg", new JpegWriterOptions { Quality = 90, Subsampling = ChromaSubsampling.Subsample444 });

Properties

HorizontalSampling

The horizontal sampling factor, 1 to 4.

public int HorizontalSampling { get; init; }

Property Value

int

Id

The component identifier from the frame header.

public int Id { get; init; }

Property Value

int

VerticalSampling

The vertical sampling factor, 1 to 4.

public int VerticalSampling { get; init; }

Property Value

int