Browse Source

Fix Entropy Crop

Former-commit-id: bef320055b03844132eeaad17397791b95baa087
Former-commit-id: 8f2a8bfdcbe4b328635449b668880e26ecbfa635
Former-commit-id: 7a1afac9bb3bf9d85fb3d4f84bf00b6dc20491d4
af/merge-core
James Jackson-South 10 years ago
parent
commit
ce6a80c398
  1. 21
      src/ImageProcessorCore/Samplers/EntropyCrop.cs

21
src/ImageProcessorCore/Samplers/EntropyCrop.cs

@ -69,26 +69,21 @@ namespace ImageProcessorCore.Samplers
}
int targetY = this.cropRectangle.Y;
int startX = targetRectangle.X;
int targetX = this.cropRectangle.X;
int endX = this.cropRectangle.Width;
int maxX = this.cropRectangle.Right - 1;
int maxY = this.cropRectangle.Bottom - 1;
int targetBottom = this.cropRectangle.Bottom;
int startX = this.cropRectangle.X;
int endX = this.cropRectangle.Right;
Parallel.For(
startY,
endY,
y =>
{
for (int x = startX; x < endX; x++)
if (y >= targetY && y < targetBottom)
{
int offsetY = y + targetY;
offsetY = offsetY.Clamp(0, maxY);
int offsetX = x + targetX;
offsetX = offsetX.Clamp(0, maxX);
target[x, y] = source[offsetX, offsetY];
for (int x = startX; x < endX; x++)
{
target[x - startX, y - targetY] = source[x, y];
}
}
this.OnRowProcessed();

Loading…
Cancel
Save