Represents a collection of PipelineElements.
Namespace:
Aurigma.GraphicsMill
Assembly:
Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)
public sealed class Pipeline : Collection<PipelineElement>
Pipelines allow reading and writing image files and processing them without the necessity to load a whole bitmap into memory. This essentially means that you can process large images without getting out-of-memory errors, even on an x86 platform. Pipelines offer the following benefites:
This code sample reads an image from JPEG file, crops a square from its center, adjusts brightness, and writes the result to another file.
using (var reader = ImageReader.Create(@"Images\in.jpg")) { var rect = new System.Drawing.Rectangle() { X = Math.Max((reader.Width - reader.Height) / 2, 0), Y = Math.Max((reader.Height - reader.Width) / 2, 0), Width = Math.Min(reader.Width, reader.Height), Height = Math.Min(reader.Width, reader.Height) }; using (var crop = new Crop(rect)) using (var brightness = new Brightness()) using (var writer = ImageWriter.Create(@"Images\Output\out.jpg")) { Pipeline.Run(reader + crop + brightness + writer); } }
The following code shows how to create two 128x128 and 2048x2048 thumbnails for a single image.
using (var reader = ImageReader.Create(@"Images\in.jpg")) { var resizeBig = new Pipeline() { new Resize(2048, 0), ImageWriter.Create(@"Images\Output\out_2048.jpg") }; var resizeSmall = new Pipeline() { new Resize(128, 0), ImageWriter.Create(@"Images\Output\out_128.jpg") }; reader.Receivers.Add(resizeBig.Build()); reader.Receivers.Add(resizeSmall.Build()); Pipeline.Run(reader); resizeBig.DisposeAllElements(); resizeSmall.DisposeAllElements(); }