Class SamplingOptions
- Namespace
- Egami.Operations
- Assembly
- Egami.dll
How a transform or warp samples the source: the filter, the color space it blends in, what samples outside the source read, and the background color.
public record SamplingOptions : IEquatable<SamplingOptions>
- Inheritance
-
SamplingOptions
- Implements
- Derived
- Inherited Members
Examples
// Keep the input's size (and the matrix's translation), fill the uncovered corners with white, blend in linear light.
TransformOptions keep = new()
{
Viewport = new Rect(0, 0, photo.Width, photo.Height),
Background = Rgba8.White,
ColorSpace = ColorSpace.Linear,
};
photo.Apply(ops => ops.Transform(Matrix3x2.CreateRotation(0.2f, new Vector2(photo.Width / 2f, photo.Height / 2f)), keep), Ct);
// Wrap extends the image as a tiling, so a turned copy fills the whole canvas.
using Raster<Rgba8> pattern = photo.Derive(ops => ops.Transform(Matrix3x2.CreateRotation(0.5f), new TransformOptions
{
Viewport = new Rect(0, 0, 800, 600),
Edges = EdgeMode.Wrap,
Filter = ResampleFilter.Lanczos3,
}), Ct);
Properties
Background
Gets the color of canvas the image does not reach and of samples outside it under Transparent. Defaults to transparent black.
public Rgba8 Background { get; init; }
Property Value
ColorSpace
Gets the color space the filter blends in. Defaults to Encoded, as for Resize.
public ColorSpace ColorSpace { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not defined.
Edges
Gets what samples outside the source read. Transparent (the default) reads Background, so the image's edges blend smoothly into it; Clamp, Mirror and Wrap extend the image, so a Wrap transform fills the whole canvas with a tiling.
public EdgeMode Edges { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not defined.
Filter
Gets the filter. Where the image keeps or gains size, each output pixel blends the filter's 2D kernel around its source point, as Rotate does; where it shrinks or tilts away, the filter weighs an ellipse that covers the pixel's footprint (elliptical weighted averaging), so fine detail fades instead of aliasing. Defaults to Bicubic.
public ResampleFilter Filter { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not defined.