Delegate RowBandAction
- Namespace
- Egami.Operations
- Assembly
- Egami.dll
Processes a band of rows: rows start (inclusive) to end (exclusive).
public delegate void RowBandAction(int start, int end)
Parameters
Examples
/// <summary>Black or white per pixel: ForEachBand gives each worker a band of rows from start to end.</summary>
private sealed class Threshold(float level) : IRasterOperation
{
public Size OutputSize(Size input) => input;
public void Run<TPixel>(OperationInput<TPixel> input)
where TPixel : unmanaged, IPixelType<TPixel>
{
RowBandAction band = (start, end) =>
{
for (int y = start; y < end; y++)
{
Span<TPixel> source = input.Source.Row(y), destination = input.Destination.Row(y);
for (int x = 0; x < source.Length; x++)
{
Vector4 v = source[x].ToScaled();
float on = ((0.2126f * v.X) + (0.7152f * v.Y) + (0.0722f * v.Z)) >= level ? 1 : 0;
destination[x] = TPixel.FromScaled(new Vector4(on, on, on, v.W));
}
}
};
input.ForEachBand(band);
}
}