Skip to content

interfaces for Image #430

@vpenades

Description

@vpenades

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

In same cases, we can have a collection of images with varying pixel types, and with the current API implementation it's difficult to have a collection of varying pixel types, the only way to do it now is to cast down to Object collections.

I propose these interfaces:

public interface IImage
{
    Type PixelType { get; }

    int Width { get; }
    int Height { get; }

    ImageMetaData MetaData { get; }
}

this would allow to do Linq queries over image collections like:

var imageCollection = new List<IImage>();
...
var metadataCollection = imageCollection
                       .Where(img=>Width > 100)
                       .Where(img => img.PixelType == typeof(rgba32) || img.PixelType == (argb32))
                       .Select(img => img.MetaData);

Also, an interface like this:

public interface IImage<TPixel> : IImage
{
    TPixel this[int x, int y] {get;set;}
}

Would be helpful, in case we want to abstract the concept of "image"
Useful cases I can think about:

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions