public void Execute() { // performa any processing logic you wan here, in this case we are going to // clone the source image then apply the changes requested before cropping // down and using an image brush to draw that portion the the original image // so clone out our source image so we can apply // various effects to it without mutating the origional yet. using (var clone = source.Clone(recursiveImageProcessor.InnerProcessingOperations)) { // crop it down to just the size of the shape clone.Mutate(x => x.Crop((Rectangle)recursiveImageProcessor.Path.Bounds)); // use an image brush to apply cloned image as the source for filling the shape var brush = new ImageBrush(clone); // grab hold of an inbox image processor that can fill paths with a brush to allow it to do the hard pixel pushing for us var processor = new FillPathProcessor(recursiveImageProcessor.Options, brush, recursiveImageProcessor.Path); using (var p = processor.CreatePixelSpecificProcessor <TPixel>(configuration, source, sourceRectangle)) { // fill the shape using the image brush p.Execute(); } } }
public void OtherShape() { var imageSize = new Rectangle(0, 0, 500, 500); var path = new EllipsePolygon(1, 1, 23); var processor = new FillPathProcessor(new ImageSharp.Drawing.Processing.ShapeGraphicsOptions() { GraphicsOptions = { Antialias = true } }, Brushes.Solid(Color.Red), path); var pixelProcessor = processor.CreatePixelSpecificProcessor <Rgba32>(null, null, imageSize); Assert.IsType <FillRegionProcessor <Rgba32> >(pixelProcessor); }
public void RectangleFloatAndAntialias() { var imageSize = new Rectangle(0, 0, 500, 500); var floatRect = new RectangleF(10.5f, 10.5f, 400.6f, 400.9f); var expectedRect = new Rectangle(10, 10, 400, 400); var path = new RectangularPolygon(floatRect); var processor = new FillPathProcessor(new ImageSharp.Drawing.Processing.ShapeGraphicsOptions() { GraphicsOptions = { Antialias = true } }, Brushes.Solid(Color.Red), path); var pixelProcessor = processor.CreatePixelSpecificProcessor <Rgba32>(null, null, imageSize); Assert.IsType <FillRegionProcessor <Rgba32> >(pixelProcessor); }
public void IntRectangle() { var imageSize = new Rectangle(0, 0, 500, 500); var expectedRect = new Rectangle(10, 10, 400, 400); var path = new RectangularPolygon(expectedRect); var processor = new FillPathProcessor(new ImageSharp.Drawing.Processing.ShapeGraphicsOptions() { GraphicsOptions = { Antialias = true } }, Brushes.Solid(Color.Red), path); var pixelProcessor = processor.CreatePixelSpecificProcessor <Rgba32>(null, null, imageSize); var fill = Assert.IsType <FillProcessor <Rgba32> >(pixelProcessor); Assert.Equal(expectedRect, fill.GetProtectedValue <Rectangle>("SourceRectangle")); }
public void FloatRectAntialiasingOff() { var imageSize = new Rectangle(0, 0, 500, 500); var floatRect = new RectangleF(10.5f, 10.5f, 400.6f, 400.9f); var expectedRect = new Rectangle(10, 10, 400, 400); var path = new RectangularPolygon(floatRect); var processor = new FillPathProcessor( new ShapeGraphicsOptions() { GraphicsOptions = { Antialias = false } }, Brushes.Solid(Color.Red), path); IImageProcessor <Rgba32> pixelProcessor = processor.CreatePixelSpecificProcessor <Rgba32>(null, null, imageSize); FillProcessor <Rgba32> fill = Assert.IsType <FillProcessor <Rgba32> >(pixelProcessor); Assert.Equal(expectedRect, fill.GetProtectedValue <Rectangle>("SourceRectangle")); }