From d6928ee78775b417a5bcd5d1197aa9f68aed51e2 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Fri, 16 Dec 2016 11:40:13 +1100 Subject: [PATCH] Rename Blend to DrawImage --- README.md | 2 +- src/ImageSharp/Drawing/Draw.cs | 1 - .../Overlays/Blend.cs => Drawing/DrawImage.cs} | 10 +++++----- .../Processors/DrawImageProcessor.cs} | 8 ++++---- .../Filters/BlendTest.cs => Drawing/DrawImageTest.cs} | 8 ++++---- 5 files changed, 14 insertions(+), 15 deletions(-) rename src/ImageSharp/{Filters/Overlays/Blend.cs => Drawing/DrawImage.cs} (80%) rename src/ImageSharp/{Filters/Processors/Overlays/BlendProcessor.cs => Drawing/Processors/DrawImageProcessor.cs} (90%) rename tests/ImageSharp.Tests/{Processors/Filters/BlendTest.cs => Drawing/DrawImageTest.cs} (73%) diff --git a/README.md b/README.md index 4a40d324a..8648542bd 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,6 @@ git clone https://github.com/JimBobSquarePants/ImageSharp - [x] BackgroundColor - [x] Brightness - [x] Pixelate - - [x] Blend - [ ] Mask - [x] Oil Painting - [x] Vignette @@ -161,6 +160,7 @@ git clone https://github.com/JimBobSquarePants/ImageSharp - [x] Pen (Solid, Dash, Custom) - [x] Line drawing - [x] Complex Polygons (Fill, draw) + - [x] DrawImage - [ ] Gradient brush (Need help) - Other stuff I haven't thought of. diff --git a/src/ImageSharp/Drawing/Draw.cs b/src/ImageSharp/Drawing/Draw.cs index 5c2f208a3..8259ad3a0 100644 --- a/src/ImageSharp/Drawing/Draw.cs +++ b/src/ImageSharp/Drawing/Draw.cs @@ -12,7 +12,6 @@ namespace ImageSharp using Drawing.Pens; using Drawing.Processors; using Drawing.Shapes; - using Processors; /// /// Extension methods for the type. diff --git a/src/ImageSharp/Filters/Overlays/Blend.cs b/src/ImageSharp/Drawing/DrawImage.cs similarity index 80% rename from src/ImageSharp/Filters/Overlays/Blend.cs rename to src/ImageSharp/Drawing/DrawImage.cs index 4a1fc534d..7196f1abb 100644 --- a/src/ImageSharp/Filters/Overlays/Blend.cs +++ b/src/ImageSharp/Drawing/DrawImage.cs @@ -13,7 +13,7 @@ namespace ImageSharp public static partial class ImageExtensions { /// - /// Combines the given image together with the current one by blending their pixels. + /// Draws the given image together with the current one by blending their pixels. /// /// The pixel format. /// The packed format. uint, long, float. @@ -25,11 +25,11 @@ namespace ImageSharp where TColor : struct, IPackedPixel where TPacked : struct { - return Blend(source, image, percent, default(Size), default(Point)); + return DrawImage(source, image, percent, default(Size), default(Point)); } /// - /// Combines the given image together with the current one by blending their pixels. + /// Draws the given image together with the current one by blending their pixels. /// /// The image this method extends. /// The image to blend with the currently processing image. @@ -39,7 +39,7 @@ namespace ImageSharp /// The size to draw the blended image. /// The location to draw the blended image. /// The . - public static Image Blend(this Image source, Image image, int percent, Size size, Point location) + public static Image DrawImage(this Image source, Image image, int percent, Size size, Point location) where TColor : struct, IPackedPixel where TPacked : struct { @@ -53,7 +53,7 @@ namespace ImageSharp location = Point.Empty; } - return source.Process(source.Bounds, new BlendProcessor(image, size, location, percent)); + return source.Process(source.Bounds, new DrawImageProcessor(image, size, location, percent)); } } } \ No newline at end of file diff --git a/src/ImageSharp/Filters/Processors/Overlays/BlendProcessor.cs b/src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs similarity index 90% rename from src/ImageSharp/Filters/Processors/Overlays/BlendProcessor.cs rename to src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs index fdcc7b129..0c2f0ba2e 100644 --- a/src/ImageSharp/Filters/Processors/Overlays/BlendProcessor.cs +++ b/src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // @@ -14,18 +14,18 @@ namespace ImageSharp.Processors /// /// The pixel format. /// The packed format. uint, long, float. - public class BlendProcessor : ImageFilteringProcessor + public class DrawImageProcessor : ImageFilteringProcessor where TColor : struct, IPackedPixel where TPacked : struct { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The image to blend with the currently processing image. /// The size to draw the blended image. /// The location to draw the blended image. /// The opacity of the image to blend. Between 0 and 100. - public BlendProcessor(Image image, Size size, Point location, int alpha = 100) + public DrawImageProcessor(Image image, Size size, Point location, int alpha = 100) { Guard.MustBeBetweenOrEqualTo(alpha, 0, 100, nameof(alpha)); this.Image = image; diff --git a/tests/ImageSharp.Tests/Processors/Filters/BlendTest.cs b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs similarity index 73% rename from tests/ImageSharp.Tests/Processors/Filters/BlendTest.cs rename to tests/ImageSharp.Tests/Drawing/DrawImageTest.cs index 8c3bf932f..3db44c562 100644 --- a/tests/ImageSharp.Tests/Processors/Filters/BlendTest.cs +++ b/tests/ImageSharp.Tests/Drawing/DrawImageTest.cs @@ -10,12 +10,12 @@ namespace ImageSharp.Tests using Xunit; - public class BlendTest : FileTestBase + public class DrawImageTest : FileTestBase { [Fact] - public void ImageShouldApplyBlendFilter() + public void ImageShouldApplyDrawImageFilter() { - string path = CreateOutputDirectory("Blend"); + string path = CreateOutputDirectory("Drawing", "DrawImage"); Image blend;// = new Image(400, 400); // blend.BackgroundColor(Color.RebeccaPurple); @@ -31,7 +31,7 @@ namespace ImageSharp.Tests using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) { - image.Blend(blend, 75, new Size(image.Width / 2, image.Height / 2), new Point(image.Width / 4, image.Height / 4)) + image.DrawImage(blend, 75, new Size(image.Width / 2, image.Height / 2), new Point(image.Width / 4, image.Height / 4)) .Save(output); } }