Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private static (Size, Rectangle) CalculateMinRectangle(
// Don't upscale
if (width > sourceWidth || height > sourceHeight)
{
return (new Size(sourceWidth, sourceWidth), new Rectangle(0, 0, sourceWidth, sourceHeight));
return (new Size(sourceWidth, sourceHeight), new Rectangle(0, 0, sourceWidth, sourceHeight));
}

// Find the shortest distance to go.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Transforms;
using SixLabors.Primitives;

using Xunit;

Expand Down Expand Up @@ -31,5 +33,24 @@ public void CalculateResizeWorkerHeightInWindowBands(
int actualCount = ResizeHelper.CalculateResizeWorkerHeightInWindowBands(windowDiameter, width, sizeLimitHintInBytes);
Assert.Equal(expectedCount, actualCount);
}

[Fact]
public void CalculateMinRectangleWhenSourceIsSmallerThanTarget()
{
var sourceSize = new Size(200, 100);
var target = new Size(400, 200);

var actual = ResizeHelper.CalculateTargetLocationAndBounds(
sourceSize,
new ResizeOptions{
Mode = ResizeMode.Min,
Size = target
},
target.Width,
target.Height);

Assert.Equal(sourceSize, actual.Item1);
Assert.Equal(new Rectangle(0, 0, sourceSize.Width, sourceSize.Height), actual.Item2);
}
}
}