Class Image<TPixel>
- Namespace
- SixLabors.ImageSharp
- Assembly
- SixLabors.ImageSharp.dll
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.
public sealed class Image<TPixel> : Image, IDisposable, IConfigurationProvider where TPixel : unmanaged, IPixel<TPixel>
Type Parameters
TPixelThe pixel format.
- Inheritance
-
Image<TPixel>
- Implements
- Inherited Members
- Extension Methods
Constructors
Image(Configuration, int, int)
Initializes a new instance of the Image<TPixel> class with the height and the width of the image.
public Image(Configuration configuration, int width, int height)
Parameters
configurationConfigurationThe configuration providing initialization code which allows extending the library.
widthintThe width of the image in pixels.
heightintThe height of the image in pixels.
Image(Configuration, int, int, TPixel)
Initializes a new instance of the Image<TPixel> class with the height and the width of the image.
public Image(Configuration configuration, int width, int height, TPixel backgroundColor)
Parameters
configurationConfigurationThe configuration providing initialization code which allows extending the library.
widthintThe width of the image in pixels.
heightintThe height of the image in pixels.
backgroundColorTPixelThe color to initialize the pixels with.
Image(int, int)
Initializes a new instance of the Image<TPixel> class with the height and the width of the image.
public Image(int width, int height)
Parameters
Image(int, int, TPixel)
Initializes a new instance of the Image<TPixel> class with the height and the width of the image.
public Image(int width, int height, TPixel backgroundColor)
Parameters
widthintThe width of the image in pixels.
heightintThe height of the image in pixels.
backgroundColorTPixelThe color to initialize the pixels with.
Properties
Frames
Gets the collection of image frames.
public ImageFrameCollection<TPixel> Frames { get; }
Property Value
- ImageFrameCollection<TPixel>
this[int, int]
Gets or sets the pixel at the specified position.
public TPixel this[int x, int y] { get; set; }
Parameters
xintThe x-coordinate of the pixel. Must be greater than or equal to zero and less than the width of the image.
yintThe y-coordinate of the pixel. Must be greater than or equal to zero and less than the height of the image.
Property Value
- TPixel
The
at the specified position.
Exceptions
- ArgumentOutOfRangeException
Thrown when the provided (x,y) coordinates are outside the image boundary.
NonGenericFrameCollection
protected override ImageFrameCollection NonGenericFrameCollection { get; }
Property Value
Methods
Clone()
Clones the current image
public Image<TPixel> Clone()
Returns
- Image<TPixel>
Returns a new image with all the same metadata as the original.
Clone(Configuration)
Clones the current image with the given configuration.
public Image<TPixel> Clone(Configuration configuration)
Parameters
configurationConfigurationThe configuration providing initialization code which allows extending the library.
Returns
- 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.
public override Image<TPixel2> CloneAs<TPixel2>(Configuration configuration) where TPixel2 : unmanaged, IPixel<TPixel2>
Parameters
configurationConfigurationThe configuration providing initialization code which allows extending the library.
Returns
- Image<TPixel2>
The Image<TPixel>.
Type Parameters
TPixel2The pixel format.
CopyPixelDataTo(Span<byte>)
Copy image pixels to destination.
public void CopyPixelDataTo(Span<byte> destination)
Parameters
CopyPixelDataTo(Span<TPixel>)
Copy image pixels to destination.
public void CopyPixelDataTo(Span<TPixel> destination)
Parameters
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 thememory's Span<T>
might lead to memory corruption.
public bool DangerousTryGetSinglePixelMemory(out Memory<TPixel> memory)
Parameters
Returns
Dispose(bool)
protected override void Dispose(bool disposing)
Parameters
disposingbool
ProcessPixelRows(PixelAccessorAction<TPixel>)
Execute processPixels to process image pixels in a safe and efficient manner.
public void ProcessPixelRows(PixelAccessorAction<TPixel> processPixels)
Parameters
processPixelsPixelAccessorAction<TPixel>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.
public void ProcessPixelRows<TPixel2>(Image<TPixel2> image2, PixelAccessorAction<TPixel, TPixel2> processPixels) where TPixel2 : unmanaged, IPixel<TPixel2>
Parameters
image2Image<TPixel2>The second image.
processPixelsPixelAccessorAction<TPixel, TPixel2>The PixelAccessorAction<TPixel1, TPixel2> defining the pixel operations.
Type Parameters
TPixel2The 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.
public void ProcessPixelRows<TPixel2, TPixel3>(Image<TPixel2> image2, Image<TPixel3> image3, PixelAccessorAction<TPixel, TPixel2, TPixel3> processPixels) where TPixel2 : unmanaged, IPixel<TPixel2> where TPixel3 : unmanaged, IPixel<TPixel3>
Parameters
image2Image<TPixel2>The second image.
image3Image<TPixel3>The third image.
processPixelsPixelAccessorAction<TPixel, TPixel2, TPixel3>The PixelAccessorAction<TPixel1, TPixel2, TPixel3> defining the pixel operations.
Type Parameters
TPixel2The pixel type of the second image.
TPixel3The pixel type of the third image.
ToString()
public override string ToString()