Browse Source

Tweak bounds clamping

pull/2588/head
James Jackson-South 2 years ago
parent
commit
4f8ea7f677
  1. 11
      src/ImageSharp/Formats/AnimationUtilities.cs

11
src/ImageSharp/Formats/AnimationUtilities.cs

@ -148,11 +148,12 @@ internal static class AnimationUtilities
PixelOperations<TPixel>.Instance.FromVector4Destructive(configuration, result, resultFrame.DangerousGetPixelRowMemory(y).Span, PixelConversionModifiers.Scale);
}
Rectangle bounds = Rectangle.FromLTRB(
left = Numerics.Clamp(left, 0, resultFrame.Width - 1),
top = Numerics.Clamp(top, 0, resultFrame.Height - 1),
Numerics.Clamp(right, left + 1, resultFrame.Width),
Numerics.Clamp(bottom, top + 1, resultFrame.Height));
left = Math.Max(0, Math.Min(left, resultFrame.Width - 1));
top = Math.Max(0, Math.Min(top, resultFrame.Height - 1));
right = Math.Max(left + 1, Math.Min(right, resultFrame.Width));
bottom = Math.Max(top + 1, Math.Min(bottom, resultFrame.Height));
Rectangle bounds = Rectangle.FromLTRB(left, top, right, bottom);
// Webp requires even bounds
if (clampingMode == ClampingMode.Even)

Loading…
Cancel
Save