ImageSharp icon indicating copy to clipboard operation
ImageSharp copied to clipboard

Official package, version 1.0.3 does not have any Image.this[] or Image.Pixel - 100% using the new version

Open speciesunknown opened this issue 5 years ago • 2 comments

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

I have seen this issue before but the reason was due to another provider having an outdated version in nuget.

I have verified that this is not the case. I have the latest version, 1.0.3.

This code which appears in the documentation does not compile as there is no Pixel or this[] or other visible method to access individual pixels.

image

Steps to Reproduce

System Configuration

.net core 2.1

  • ImageSharp version: 1.0.3
  • Other ImageSharp packages and versions:
  • Environment (Operating system, version and so on):
  • .NET Framework version:
  • Additional information: Author(s): Six Labors and contributors Date published: Wednesday, February 17, 2021 (2/17/2021)

speciesunknown avatar Aug 31 '21 18:08 speciesunknown

I found the problem

I should be using the following code:

using (var image = await SixLabors.ImageSharp.Image.LoadAsync<Rgba32>(fileName))
{
    var first = image[0, 0];
}

Only the pixel typed version allows access to individual pixels.

speciesunknown avatar Aug 31 '21 19:08 speciesunknown

Exactly, this change happened long time ago in beta 7.

If performance matters, use .GetPixelRowSpan(y) instead of the [x, y] indexer: https://docs.sixlabors.com/articles/imagesharp/pixelbuffers.html#efficient-pixel-manipulation

However be aware that the above method will be replaced in ImageSharp 2.0 unfortunately, see #1739.

antonfirsov avatar Aug 31 '21 19:08 antonfirsov