diff --git a/src/ImageSharp/Samplers/Effects/OilPainting.cs b/src/ImageSharp/Filters/Effects/OilPainting.cs
similarity index 100%
rename from src/ImageSharp/Samplers/Effects/OilPainting.cs
rename to src/ImageSharp/Filters/Effects/OilPainting.cs
diff --git a/src/ImageSharp/Samplers/Processors/Effects/OilPaintingProcessor.cs b/src/ImageSharp/Filters/Processors/Effects/OilPaintingProcessor.cs
similarity index 92%
rename from src/ImageSharp/Samplers/Processors/Effects/OilPaintingProcessor.cs
rename to src/ImageSharp/Filters/Processors/Effects/OilPaintingProcessor.cs
index 77b7a158fe..f368152fcb 100644
--- a/src/ImageSharp/Samplers/Processors/Effects/OilPaintingProcessor.cs
+++ b/src/ImageSharp/Filters/Processors/Effects/OilPaintingProcessor.cs
@@ -15,12 +15,12 @@ namespace ImageSharp.Processors
/// Adapted from by Dewald Esterhuizen.
/// The pixel format.
/// The packed format. uint, long, float.
- public class OilPaintingProcessor : ImageSamplingProcessor
+ public class OilPaintingProcessor : ImageFilteringProcessor
where TColor : struct, IPackedPixel
where TPacked : struct
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
///
/// The number of intensity levels. Higher values result in a broader range of color intensities forming part of the result image.
@@ -48,7 +48,7 @@ namespace ImageSharp.Processors
public int BrushSize { get; }
///
- public override void Apply(ImageBase target, ImageBase source, Rectangle targetRectangle, Rectangle sourceRectangle, int startY, int endY)
+ protected override void Apply(ImageBase source, Rectangle sourceRectangle, int startY, int endY)
{
int startX = sourceRectangle.X;
int endX = sourceRectangle.Right;
@@ -67,8 +67,9 @@ namespace ImageSharp.Processors
startX = 0;
}
+ TColor[] target = new TColor[source.Width * source.Height];
using (PixelAccessor sourcePixels = source.Lock())
- using (PixelAccessor targetPixels = target.Lock())
+ using (PixelAccessor targetPixels = target.Lock(source.Width, source.Height))
{
Parallel.For(
minY,
@@ -142,14 +143,15 @@ namespace ImageSharp.Processors
float green = Math.Abs(greenBin[maxIndex] / maxIntensity);
float blue = Math.Abs(blueBin[maxIndex] / maxIntensity);
- Vector4 targetColor = targetPixels[x, y].ToVector4();
TColor packed = default(TColor);
- packed.PackFromVector4(new Vector4(red, green, blue, targetColor.Z));
+ packed.PackFromVector4(new Vector4(red, green, blue, sourcePixels[x, y].ToVector4().W));
targetPixels[x, y] = packed;
}
}
});
}
+
+ source.SetPixels(source.Width, source.Height, target);
}
}
}
\ No newline at end of file
diff --git a/tests/ImageSharp.Tests/Processors/Samplers/OilPaintTest.cs b/tests/ImageSharp.Tests/Processors/Filters/OilPaintTest.cs
similarity index 70%
rename from tests/ImageSharp.Tests/Processors/Samplers/OilPaintTest.cs
rename to tests/ImageSharp.Tests/Processors/Filters/OilPaintTest.cs
index 8b5ff3f513..e6fa22a6fd 100644
--- a/tests/ImageSharp.Tests/Processors/Samplers/OilPaintTest.cs
+++ b/tests/ImageSharp.Tests/Processors/Filters/OilPaintTest.cs
@@ -15,8 +15,8 @@ namespace ImageSharp.Tests
public static readonly TheoryData> OilPaintValues
= new TheoryData>
{
- new Tuple(15,10),
- new Tuple(6,5)
+ new Tuple(15, 10),
+ new Tuple(8, 5)
};
[Theory]
@@ -32,8 +32,11 @@ namespace ImageSharp.Tests
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
- image.OilPaint(value.Item1, value.Item2)
- .Save(output);
+ if (value.Item2 < image.Width && value.Item2 < image.Height)
+ {
+ image.OilPaint(value.Item1, value.Item2)
+ .Save(output);
+ }
}
}
}
@@ -51,8 +54,11 @@ namespace ImageSharp.Tests
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
- image.OilPaint(value.Item1, value.Item2, new Rectangle(10, 10, image.Width / 2, image.Height / 2))
- .Save(output);
+ if (value.Item2 < image.Width && value.Item2 < image.Height)
+ {
+ image.OilPaint(value.Item1, value.Item2, new Rectangle(image.Width / 4, image.Width / 4, image.Width / 2, image.Height / 2))
+ .Save(output);
+ }
}
}
}