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
TPixel
The 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
configuration
ConfigurationThe configuration providing initialization code which allows extending the library.
width
intThe width of the image in pixels.
height
intThe 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
configuration
ConfigurationThe configuration providing initialization code which allows extending the library.
width
intThe width of the image in pixels.
height
intThe height of the image in pixels.
backgroundColor
TPixelThe 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
width
intThe width of the image in pixels.
height
intThe height of the image in pixels.
backgroundColor
TPixelThe 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
x
intThe x-coordinate of the pixel. Must be greater than or equal to zero and less than the width of the image.
y
intThe 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
configuration
ConfigurationThe 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
configuration
ConfigurationThe configuration providing initialization code which allows extending the library.
Returns
- Image<TPixel2>
The Image<TPixel>.
Type Parameters
TPixel2
The 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
disposing
bool
ProcessPixelRows(PixelAccessorAction<TPixel>)
Execute processPixels
to process image pixels in a safe and efficient manner.
public void ProcessPixelRows(PixelAccessorAction<TPixel> processPixels)
Parameters
processPixels
PixelAccessorAction<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
image2
Image<TPixel2>The second image.
processPixels
PixelAccessorAction<TPixel, TPixel2>The PixelAccessorAction<TPixel1, TPixel2> defining the pixel operations.
Type Parameters
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.
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
image2
Image<TPixel2>The second image.
image3
Image<TPixel3>The third image.
processPixels
PixelAccessorAction<TPixel, TPixel2, TPixel3>The PixelAccessorAction<TPixel1, TPixel2, TPixel3> defining the pixel operations.
Type Parameters
TPixel2
The pixel type of the second image.
TPixel3
The pixel type of the third image.
ToString()
public override string ToString()