Assemble Pipeline manually

View as Markdown

AdvancedBranched PipelineResize

In general, the Pipeline API assumes that each element may have several receivers, and each of them receives the same data to process. Here we illustrate how to implement the use case shown in the Create linear pipeline sample using the Pipeline class only for running, while constructing the data flow manually.

You can read more information about pipelines in the documentation.

Code Snippet

// reader --->  resize  --->  writer
using (var reader = ImageReader.Create("Venice.jpg"))
using (var resize = new Resize(320, 0, ResizeInterpolationMode.High))
using (var writer = ImageWriter.Create("Venice_small.jpg"))
{
    // Reader element sends data to resize element
    reader.Receivers.Add(resize);

    // Resize element sends data to writer element
    resize.Receivers.Add(writer);

    // Pass first element
    Pipeline.Run(reader);
}

Input

Venice.jpg

Venice.jpg

Output

Venice_small.jpg

Venice_small.jpg

Used APIs