Browse Source

Rename Blend to DrawImage

pull/41/head
James Jackson-South 9 years ago
parent
commit
d6928ee787
  1. 2
      README.md
  2. 1
      src/ImageSharp/Drawing/Draw.cs
  3. 10
      src/ImageSharp/Drawing/DrawImage.cs
  4. 8
      src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs
  5. 8
      tests/ImageSharp.Tests/Drawing/DrawImageTest.cs

2
README.md

@ -147,7 +147,6 @@ git clone https://github.com/JimBobSquarePants/ImageSharp
- [x] BackgroundColor - [x] BackgroundColor
- [x] Brightness - [x] Brightness
- [x] Pixelate - [x] Pixelate
- [x] Blend
- [ ] Mask - [ ] Mask
- [x] Oil Painting - [x] Oil Painting
- [x] Vignette - [x] Vignette
@ -161,6 +160,7 @@ git clone https://github.com/JimBobSquarePants/ImageSharp
- [x] Pen (Solid, Dash, Custom) - [x] Pen (Solid, Dash, Custom)
- [x] Line drawing - [x] Line drawing
- [x] Complex Polygons (Fill, draw) - [x] Complex Polygons (Fill, draw)
- [x] DrawImage
- [ ] Gradient brush (Need help) - [ ] Gradient brush (Need help)
- Other stuff I haven't thought of. - Other stuff I haven't thought of.

1
src/ImageSharp/Drawing/Draw.cs

@ -12,7 +12,6 @@ namespace ImageSharp
using Drawing.Pens; using Drawing.Pens;
using Drawing.Processors; using Drawing.Processors;
using Drawing.Shapes; using Drawing.Shapes;
using Processors;
/// <summary> /// <summary>
/// Extension methods for the <see cref="Image{TColor, TPacked}"/> type. /// Extension methods for the <see cref="Image{TColor, TPacked}"/> type.

10
src/ImageSharp/Filters/Overlays/Blend.cs → src/ImageSharp/Drawing/DrawImage.cs

@ -13,7 +13,7 @@ namespace ImageSharp
public static partial class ImageExtensions public static partial class ImageExtensions
{ {
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam> /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
@ -25,11 +25,11 @@ namespace ImageSharp
where TColor : struct, IPackedPixel<TPacked> where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct where TPacked : struct
{ {
return Blend(source, image, percent, default(Size), default(Point)); return DrawImage(source, image, percent, default(Size), default(Point));
} }
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
/// <param name="source">The image this method extends.</param> /// <param name="source">The image this method extends.</param>
/// <param name="image">The image to blend with the currently processing image.</param> /// <param name="image">The image to blend with the currently processing image.</param>
@ -39,7 +39,7 @@ namespace ImageSharp
/// <param name="size">The size to draw the blended image.</param> /// <param name="size">The size to draw the blended image.</param>
/// <param name="location">The location to draw the blended image.</param> /// <param name="location">The location to draw the blended image.</param>
/// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns> /// <returns>The <see cref="Image{TColor, TPacked}"/>.</returns>
public static Image<TColor, TPacked> Blend<TColor, TPacked>(this Image<TColor, TPacked> source, Image<TColor, TPacked> image, int percent, Size size, Point location) public static Image<TColor, TPacked> DrawImage<TColor, TPacked>(this Image<TColor, TPacked> source, Image<TColor, TPacked> image, int percent, Size size, Point location)
where TColor : struct, IPackedPixel<TPacked> where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct where TPacked : struct
{ {
@ -53,7 +53,7 @@ namespace ImageSharp
location = Point.Empty; location = Point.Empty;
} }
return source.Process(source.Bounds, new BlendProcessor<TColor, TPacked>(image, size, location, percent)); return source.Process(source.Bounds, new DrawImageProcessor<TColor, TPacked>(image, size, location, percent));
} }
} }
} }

8
src/ImageSharp/Filters/Processors/Overlays/BlendProcessor.cs → src/ImageSharp/Drawing/Processors/DrawImageProcessor.cs

@ -1,4 +1,4 @@
// <copyright file="BlendProcessor.cs" company="James Jackson-South"> // <copyright file="DrawImageProcessor.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors. // Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
// </copyright> // </copyright>
@ -14,18 +14,18 @@ namespace ImageSharp.Processors
/// </summary> /// </summary>
/// <typeparam name="TColor">The pixel format.</typeparam> /// <typeparam name="TColor">The pixel format.</typeparam>
/// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam> /// <typeparam name="TPacked">The packed format. <example>uint, long, float.</example></typeparam>
public class BlendProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked> public class DrawImageProcessor<TColor, TPacked> : ImageFilteringProcessor<TColor, TPacked>
where TColor : struct, IPackedPixel<TPacked> where TColor : struct, IPackedPixel<TPacked>
where TPacked : struct where TPacked : struct
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="BlendProcessor{TColor,TPacked}"/> class. /// Initializes a new instance of the <see cref="DrawImageProcessor{TColor,TPacked}"/> class.
/// </summary> /// </summary>
/// <param name="image">The image to blend with the currently processing image.</param> /// <param name="image">The image to blend with the currently processing image.</param>
/// <param name="size">The size to draw the blended image.</param> /// <param name="size">The size to draw the blended image.</param>
/// <param name="location">The location to draw the blended image.</param> /// <param name="location">The location to draw the blended image.</param>
/// <param name="alpha">The opacity of the image to blend. Between 0 and 100.</param> /// <param name="alpha">The opacity of the image to blend. Between 0 and 100.</param>
public BlendProcessor(Image<TColor, TPacked> image, Size size, Point location, int alpha = 100) public DrawImageProcessor(Image<TColor, TPacked> image, Size size, Point location, int alpha = 100)
{ {
Guard.MustBeBetweenOrEqualTo(alpha, 0, 100, nameof(alpha)); Guard.MustBeBetweenOrEqualTo(alpha, 0, 100, nameof(alpha));
this.Image = image; this.Image = image;

8
tests/ImageSharp.Tests/Processors/Filters/BlendTest.cs → tests/ImageSharp.Tests/Drawing/DrawImageTest.cs

@ -10,12 +10,12 @@ namespace ImageSharp.Tests
using Xunit; using Xunit;
public class BlendTest : FileTestBase public class DrawImageTest : FileTestBase
{ {
[Fact] [Fact]
public void ImageShouldApplyBlendFilter() public void ImageShouldApplyDrawImageFilter()
{ {
string path = CreateOutputDirectory("Blend"); string path = CreateOutputDirectory("Drawing", "DrawImage");
Image blend;// = new Image(400, 400); Image blend;// = new Image(400, 400);
// blend.BackgroundColor(Color.RebeccaPurple); // blend.BackgroundColor(Color.RebeccaPurple);
@ -31,7 +31,7 @@ namespace ImageSharp.Tests
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) 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); .Save(output);
} }
} }
Loading…
Cancel
Save