Class JpegComponent
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
IdintThe component identifier from the frame header.
HorizontalSamplingintThe horizontal sampling factor, 1 to 4.
VerticalSamplingintThe 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
Id
The component identifier from the frame header.
public int Id { get; init; }
Property Value
VerticalSampling
The vertical sampling factor, 1 to 4.
public int VerticalSampling { get; init; }