Skip to content

Image.Load<Rgba32> does not respect PreferContiguousImageBuffers #1983

@roeyskoe

Description

@roeyskoe

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

Following this sample: https://docs.sixlabors.com/articles/imagesharp/memorymanagement.html#enforcing-contiguous-buffers
but instead loading an image file

using (Image<Rgba32> image = Image.Load<Rgba32>(customConfig, "big.png"))

will result in discontigous memory being used.

This is probably caused by https://github.com/SixLabors/ImageSharp/blob/master/src/ImageSharp/Image.Decode.cs#L41
not passing configuration.PreferContiguousImageBuffers to Allocate2D. Adding this extra parameter fixes the issue on my use case.

I did not open a PR for that, since I am not familiar with ImageSharps internal workings and am not sure if this issue also exists elsewhere.

Steps to Reproduce

https://github.com/roeyskoe/ImageSharpContiguous

System Configuration

  • ImageSharp version: 2.0.0 (also when using latest source)
  • Other ImageSharp packages and versions: -
  • Environment (Operating system, version and so on): Windows 10 x64 10.0.19044
  • .NET Framework version: .NET 6
  • Additional information:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions