Class Image<TPixel>
Encapsulates an image, which consists of the pixel data for a graphics image and its attributes. For generic Image<TPixel>-s the pixel type is known at compile time.
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public sealed class Image<TPixel> : Image, IImage, IImageInfo, IDisposable where TPixel : struct, IPixel<TPixel>
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Constructors
| Improve this Doc View SourceImage(Configuration, Int32, Int32)
Initializes a new instance of the Image<TPixel> class with the height and the width of the image.
Declaration
public Image(Configuration configuration, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Configuration | configuration | The configuration providing initialization code which allows extending the library. |
Int32 | width | The width of the image in pixels. |
Int32 | height | The height of the image in pixels. |
Image(Configuration, Int32, Int32, TPixel)
Initializes a new instance of the Image<TPixel> class with the height and the width of the image.
Declaration
public Image(Configuration configuration, int width, int height, TPixel backgroundColor)
Parameters
Type | Name | Description |
---|---|---|
Configuration | configuration | The configuration providing initialization code which allows extending the library. |
Int32 | width | The width of the image in pixels. |
Int32 | height | The height of the image in pixels. |
TPixel | backgroundColor | The color to initialize the pixels with. |
Image(Int32, Int32)
Initializes a new instance of the Image<TPixel> class with the height and the width of the image.
Declaration
public Image(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | The width of the image in pixels. |
Int32 | height | The height of the image in pixels. |
Image(Int32, Int32, TPixel)
Initializes a new instance of the Image<TPixel> class with the height and the width of the image.
Declaration
public Image(int width, int height, TPixel backgroundColor)
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | The width of the image in pixels. |
Int32 | height | The height of the image in pixels. |
TPixel | backgroundColor | The color to initialize the pixels with. |
Properties
| Improve this Doc View SourceFrames
Gets the collection of image frames.
Declaration
public ImageFrameCollection<TPixel> Frames { get; }
Property Value
Type | Description |
---|---|
ImageFrameCollection<TPixel> |
Item[Int32, Int32]
Gets or sets the pixel at the specified position.
Declaration
public TPixel this[int x, int y] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | x | The x-coordinate of the pixel. Must be greater than or equal to zero and less than the width of the image. |
Int32 | y | The y-coordinate of the pixel. Must be greater than or equal to zero and less than the height of the image. |
Property Value
Type | Description |
---|---|
TPixel | The |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown when the provided (x,y) coordinates are outside the image boundary. |
NonGenericFrameCollection
Gets the ImageFrameCollection implementing the public Frames property.
Declaration
protected override ImageFrameCollection NonGenericFrameCollection { get; }
Property Value
Type | Description |
---|---|
ImageFrameCollection |
Overrides
Methods
| Improve this Doc View SourceClone()
Clones the current image
Declaration
public Image<TPixel> Clone()
Returns
Type | Description |
---|---|
Image<TPixel> | Returns a new image with all the same metadata as the original. |
Clone(Configuration)
Clones the current image with the given configuration.
Declaration
public Image<TPixel> Clone(Configuration configuration)
Parameters
Type | Name | Description |
---|---|---|
Configuration | configuration | The configuration providing initialization code which allows extending the library. |
Returns
Type | Description |
---|---|
Image<TPixel> | Returns a new Image<TPixel> with all the same pixel data as the original. |
CloneAs<TPixel2>(Configuration)
Returns a copy of the image in the given pixel format.
Declaration
public override Image<TPixel2> CloneAs<TPixel2>(Configuration configuration)
where TPixel2 : struct, IPixel<TPixel2>
Parameters
Type | Name | Description |
---|---|---|
Configuration | configuration | The configuration providing initialization code which allows extending the library. |
Returns
Type | Description |
---|---|
Image<TPixel2> | The Image<TPixel>. |
Type Parameters
Name | Description |
---|---|
TPixel2 | The pixel format. |
Overrides
| Improve this Doc View SourceDispose(Boolean)
Disposes the object and frees resources for the Garbage Collector.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | Whether to dispose of managed and unmanaged objects. |
Overrides
| Improve this Doc View SourceGetPixelRowSpan(Int32)
Gets the representation of the pixels as a Span<T> of contiguous memory
at row rowIndex
beginning from the first pixel on that row.
Declaration
public Span<TPixel> GetPixelRowSpan(int rowIndex)
Parameters
Type | Name | Description |
---|---|---|
Int32 | rowIndex | The row. |
Returns
Type | Description |
---|---|
Span<TPixel> | The Span<T> |
Exceptions
Type | Condition |
---|---|
ArgumentOutOfRangeException | Thrown when row index is out of range. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
| Improve this Doc View SourceTryGetSinglePixelSpan(out Span<TPixel>)
Gets the representation of the pixels as a Span<T> in the source image's pixel format stored in row major order, if the backing buffer is contiguous.
Declaration
public bool TryGetSinglePixelSpan(out Span<TPixel> span)
Parameters
Type | Name | Description |
---|---|---|
Span<TPixel> | span | The Span<T>. |
Returns
Type | Description |
---|---|
Boolean | The Boolean. |