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] 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.

1
src/ImageSharp/Drawing/Draw.cs

@ -12,7 +12,6 @@ namespace ImageSharp
using Drawing.Pens;
using Drawing.Processors;
using Drawing.Shapes;
using Processors;
/// <summary>
/// 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
{
/// <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>
/// <typeparam name="TColor">The pixel format.</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 TPacked : struct
{
return Blend(source, image, percent, default(Size), default(Point));
return DrawImage(source, image, percent, default(Size), default(Point));
}
/// <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>
/// <param name="source">The image this method extends.</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="location">The location to draw the blended image.</param>
/// <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 TPacked : struct
{
@ -53,7 +53,7 @@ namespace ImageSharp
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.
// Licensed under the Apache License, Version 2.0.
// </copyright>
@ -14,18 +14,18 @@ namespace ImageSharp.Processors
/// </summary>
/// <typeparam name="TColor">The pixel format.</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 TPacked : struct
{
/// <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>
/// <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="location">The location to draw the blended image.</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));
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;
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);
}
}
Loading…
Cancel
Save