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 SourceCopyPixelDataTo(Span<TPixel>)
Copy image pixels to destination
.
Declaration
public void CopyPixelDataTo(Span<TPixel> destination)
Parameters
Type | Name | Description |
---|---|---|
Span<TPixel> | destination | The Span<T> to copy image pixels to. |
CopyPixelDataTo(Span<Byte>)
Copy image pixels to destination
.
Declaration
public void CopyPixelDataTo(Span<byte> destination)
Parameters
Type | Name | Description |
---|---|---|
Span<Byte> | destination |
DangerousTryGetSinglePixelMemory(out Memory<TPixel>)
Gets the representation of the pixels as a Memory<T> in the source image's pixel format stored in row major order, if the backing buffer is contiguous.
To ensure the memory is contiguous, PreferContiguousImageBuffers should be set to true, preferably on a non-global configuration instance (not Default).
WARNING: Disposing or leaking the underlying image while still working with the memory
's Span<T>
might lead to memory corruption.
Declaration
public bool DangerousTryGetSinglePixelMemory(out Memory<TPixel> memory)
Parameters
Type | Name | Description |
---|---|---|
Memory<TPixel> | memory | The Memory<T> referencing the image buffer. |
Returns
Type | Description |
---|---|
Boolean | The Boolean indicating the success. |
Dispose(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 SourceProcessPixelRows(PixelAccessorAction<TPixel>)
Execute processPixels
to process image pixels in a safe and efficient manner.
Declaration
public void ProcessPixelRows(PixelAccessorAction<TPixel> processPixels)
Parameters
Type | Name | Description |
---|---|---|
PixelAccessorAction<TPixel> | processPixels | The PixelAccessorAction<TPixel> defining the pixel operations. |
ProcessPixelRows<TPixel2>(Image<TPixel2>, PixelAccessorAction<TPixel, TPixel2>)
Execute processPixels
to process pixels of multiple images in a safe and efficient manner.
Declaration
public void ProcessPixelRows<TPixel2>(Image<TPixel2> image2, PixelAccessorAction<TPixel, TPixel2> processPixels)
where TPixel2 : struct, IPixel<TPixel2>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel2> | image2 | The second image. |
PixelAccessorAction<TPixel, TPixel2> | processPixels | The PixelAccessorAction<TPixel1, TPixel2> defining the pixel operations. |
Type Parameters
Name | Description |
---|---|
TPixel2 | The pixel type of the second image. |
ProcessPixelRows<TPixel2, TPixel3>(Image<TPixel2>, Image<TPixel3>, PixelAccessorAction<TPixel, TPixel2, TPixel3>)
Execute processPixels
to process pixels of multiple images in a safe and efficient manner.
Declaration
public void ProcessPixelRows<TPixel2, TPixel3>(Image<TPixel2> image2, Image<TPixel3> image3, PixelAccessorAction<TPixel, TPixel2, TPixel3> processPixels)
where TPixel2 : struct, IPixel<TPixel2> where TPixel3 : struct, IPixel<TPixel3>
Parameters
Type | Name | Description |
---|---|---|
Image<TPixel2> | image2 | The second image. |
Image<TPixel3> | image3 | The third image. |
PixelAccessorAction<TPixel, TPixel2, TPixel3> | processPixels | The PixelAccessorAction<TPixel1, TPixel2, TPixel3> defining the pixel operations. |
Type Parameters
Name | Description |
---|---|
TPixel2 | The pixel type of the second image. |
TPixel3 | The pixel type of the third image. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |