|
|
@ -5,6 +5,7 @@ |
|
|
|
|
|
|
|
|
namespace ImageProcessorCore.Processors |
|
|
namespace ImageProcessorCore.Processors |
|
|
{ |
|
|
{ |
|
|
|
|
|
using System; |
|
|
using System.Numerics; |
|
|
using System.Numerics; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
@ -28,6 +29,24 @@ namespace ImageProcessorCore.Processors |
|
|
{ |
|
|
{ |
|
|
int startX = sourceRectangle.X; |
|
|
int startX = sourceRectangle.X; |
|
|
int endX = sourceRectangle.Right; |
|
|
int endX = sourceRectangle.Right; |
|
|
|
|
|
|
|
|
|
|
|
// Align start/end positions.
|
|
|
|
|
|
int minX = Math.Max(0, startX); |
|
|
|
|
|
int maxX = Math.Min(source.Width, endX); |
|
|
|
|
|
int minY = Math.Max(0, startY); |
|
|
|
|
|
int maxY = Math.Min(source.Height, endY); |
|
|
|
|
|
|
|
|
|
|
|
// Reset offset if necessary.
|
|
|
|
|
|
if (minX > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
startX = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (minY > 0) |
|
|
|
|
|
{ |
|
|
|
|
|
startY = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
Matrix4x4 matrix = this.Matrix; |
|
|
Matrix4x4 matrix = this.Matrix; |
|
|
bool compand = this.Compand; |
|
|
bool compand = this.Compand; |
|
|
|
|
|
|
|
|
@ -35,18 +54,20 @@ namespace ImageProcessorCore.Processors |
|
|
using (IPixelAccessor<T, TP> targetPixels = target.Lock()) |
|
|
using (IPixelAccessor<T, TP> targetPixels = target.Lock()) |
|
|
{ |
|
|
{ |
|
|
Parallel.For( |
|
|
Parallel.For( |
|
|
startY, |
|
|
minY, |
|
|
endY, |
|
|
maxY, |
|
|
this.ParallelOptions, |
|
|
this.ParallelOptions, |
|
|
y => |
|
|
y => |
|
|
{ |
|
|
|
|
|
for (int x = startX; x < endX; x++) |
|
|
|
|
|
{ |
|
|
{ |
|
|
targetPixels[x, y] = this.ApplyMatrix(sourcePixels[x, y], matrix, compand); |
|
|
int offsetY = y - startY; |
|
|
} |
|
|
for (int x = minX; x < maxX; x++) |
|
|
|
|
|
{ |
|
|
|
|
|
int offsetX = x - startX; |
|
|
|
|
|
targetPixels[offsetX, offsetY] = this.ApplyMatrix(sourcePixels[offsetX, offsetY], matrix, compand); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
this.OnRowProcessed(); |
|
|
this.OnRowProcessed(); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|