Class OperationInput<TPixel>
- Namespace
- Egami.Operations
- Assembly
- Egami.dll
Everything an operation gets for one frame.
public sealed class OperationInput<TPixel> where TPixel : unmanaged, IPixelType<TPixel>
Type Parameters
TPixelThe pixel type.
- Inheritance
-
OperationInput<TPixel>
- Inherited Members
Examples
/// <summary>Swaps red and blue, in parallel bands of rows.</summary>
public sealed class SwapRedBlue : IRasterOperation
{
public Size OutputSize(Size input) => input;
public void Run<TPixel>(OperationInput<TPixel> input)
where TPixel : unmanaged, IPixelType<TPixel>
{
input.ForEachBand((start, end) =>
{
for (int y = start; y < end; y++)
{
Span<TPixel> source = input.Source.Row(y);
Span<TPixel> destination = input.Destination.Row(y);
for (int x = 0; x < source.Length; x++)
{
Vector4 v = source[x].ToScaled();
destination[x] = TPixel.FromScaled(new Vector4(v.Z, v.Y, v.X, v.W));
}
}
});
}
}
Properties
CancellationToken
Gets the token that cancels the chain. ForEachBand(RowBandAction) checks it between bands.
public CancellationToken CancellationToken { get; }
Property Value
Context
Gets the context, for memory, limits and MaxParallelism.
public EgamiContext Context { get; }
Property Value
Destination
Gets the plane to write, sized by OutputSize(Size). Every pixel must be written.
public PixelPlane<TPixel> Destination { get; }
Property Value
- PixelPlane<TPixel>
FrameIndex
Gets the index of the frame being processed.
public int FrameIndex { get; }
Property Value
IsInPlace
Gets a value indicating whether Source and Destination are the same plane.
public bool IsInPlace { get; }
Property Value
Source
Gets the pixels to read. Do not change them unless IsInPlace.
public PixelPlane<TPixel> Source { get; }
Property Value
- PixelPlane<TPixel>
Methods
ForEachBand(RowBandAction)
Runs action over the destination's rows in bands, in parallel up to MaxParallelism,
the way built-in operations do. Bands are at least 16 rows; small images run on the calling thread.
public void ForEachBand(RowBandAction action)
Parameters
actionRowBandActionThe work for one band. Bands may run at the same time on different threads.
Exceptions
- OperationCanceledException
The chain was cancelled.