Skip to content

NearestNeighbor fails to resize with Crop Mode. #1342

@JimBobSquarePants

Description

@JimBobSquarePants

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

We're getting out of bounds exceptions when resizing with nearest neighbor. All other resamplers using the worker pipeline are fine.

I have a fix, which I will push soon. We were not using the interest working bounds properly.

Steps to Reproduce

[Theory]
[InlineData(1, 1)]
[InlineData(4, 6)]
[InlineData(2, 10)]
[InlineData(8, 1)]
[InlineData(3, 7)]
public void CanResizeNearestNeigbour(int width, int height)
{
    using (var image = new Image<Rgba32>(1, 1))
    {
        var size = new Size(width, height);
        image.Mutate(x => x
            .Resize(
                new ResizeOptions
                {
                    Size = size,
                    Sampler = KnownResamplers.NearestNeighbor
                }));

        Assert.Equal(width, image.Width);
        Assert.Equal(height, image.Height);
    }
}

System Configuration

  • ImageSharp version: v1.0.1
  • Other ImageSharp packages and versions: NA
  • Environment (Operating system, version and so on): ALL
  • .NET Framework version: ALL
  • Additional information: NA

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions