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 targetY = this.cropRectangle.Y;
int startX = targetRectangle.X; int targetBottom = this.cropRectangle.Bottom;
int targetX = this.cropRectangle.X; int startX = this.cropRectangle.X;
int endX = this.cropRectangle.Width; int endX = this.cropRectangle.Right;
int maxX = this.cropRectangle.Right - 1;
int maxY = this.cropRectangle.Bottom - 1;
Parallel.For( Parallel.For(
startY, startY,
endY, endY,
y => y =>
{ {
for (int x = startX; x < endX; x++) if (y >= targetY && y < targetBottom)
{ {
int offsetY = y + targetY; for (int x = startX; x < endX; x++)
offsetY = offsetY.Clamp(0, maxY); {
target[x - startX, y - targetY] = source[x, y];
int offsetX = x + targetX; }
offsetX = offsetX.Clamp(0, maxX);
target[x, y] = source[offsetX, offsetY];
} }
this.OnRowProcessed(); this.OnRowProcessed();

Loading…
Cancel
Save