|
|
@ -13,11 +13,6 @@ namespace ImageProcessorCore.Processors |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public class ResizeProcessor : ImageSampler |
|
|
public class ResizeProcessor : ImageSampler |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
|
|
|
/// The image used for storing the first pass pixels.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Image firstPass; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="ResizeProcessor"/> class.
|
|
|
/// Initializes a new instance of the <see cref="ResizeProcessor"/> class.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
@ -54,8 +49,6 @@ namespace ImageProcessorCore.Processors |
|
|
this.HorizontalWeights = this.PrecomputeWeights(targetRectangle.Width, sourceRectangle.Width); |
|
|
this.HorizontalWeights = this.PrecomputeWeights(targetRectangle.Width, sourceRectangle.Width); |
|
|
this.VerticalWeights = this.PrecomputeWeights(targetRectangle.Height, sourceRectangle.Height); |
|
|
this.VerticalWeights = this.PrecomputeWeights(targetRectangle.Height, sourceRectangle.Height); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.firstPass = new Image(target.Width, source.Height); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
/// <inheritdoc/>
|
|
|
@ -121,8 +114,9 @@ namespace ImageProcessorCore.Processors |
|
|
// A 2-pass 1D algorithm appears to be faster than splitting a 1-pass 2D algorithm
|
|
|
// A 2-pass 1D algorithm appears to be faster than splitting a 1-pass 2D algorithm
|
|
|
// First process the columns. Since we are not using multiple threads startY and endY
|
|
|
// First process the columns. Since we are not using multiple threads startY and endY
|
|
|
// are the upper and lower bounds of the source rectangle.
|
|
|
// are the upper and lower bounds of the source rectangle.
|
|
|
|
|
|
Image firstPass = new Image(target.Width, source.Height); |
|
|
using (PixelAccessor sourcePixels = source.Lock()) |
|
|
using (PixelAccessor sourcePixels = source.Lock()) |
|
|
using (PixelAccessor firstPassPixels = this.firstPass.Lock()) |
|
|
using (PixelAccessor firstPassPixels = firstPass.Lock()) |
|
|
using (PixelAccessor targetPixels = target.Lock()) |
|
|
using (PixelAccessor targetPixels = target.Lock()) |
|
|
{ |
|
|
{ |
|
|
Parallel.For( |
|
|
Parallel.For( |
|
|
|