Class ImageFrame<TPixel>
- Namespace
- SixLabors.ImageSharp
- Assembly
- SixLabors.ImageSharp.dll
Represents a pixel-specific image frame containing all pixel data and ImageFrameMetadata. In case of animated formats like gif, it contains the single frame in a animation. In all other cases it is the only frame of the image.
public sealed class ImageFrame<TPixel> : ImageFrame, IConfigurationProvider, IDisposable where TPixel : unmanaged, IPixel<TPixel>
Type Parameters
TPixel
The pixel format.
- Inheritance
-
ImageFrame<TPixel>
- Implements
- Inherited Members
- Extension Methods
Properties
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.
PixelBuffer
public Buffer2D<TPixel> PixelBuffer { get; }
Property Value
- Buffer2D<TPixel>
Methods
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>(ImageFrame<TPixel2>, PixelAccessorAction<TPixel, TPixel2>)
Execute processPixels
to process pixels of multiple image frames in a safe and efficient manner.
public void ProcessPixelRows<TPixel2>(ImageFrame<TPixel2> frame2, PixelAccessorAction<TPixel, TPixel2> processPixels) where TPixel2 : unmanaged, IPixel<TPixel2>
Parameters
frame2
ImageFrame<TPixel2>The second image frame.
processPixels
PixelAccessorAction<TPixel, TPixel2>The PixelAccessorAction<TPixel1, TPixel2> defining the pixel operations.
Type Parameters
TPixel2
The pixel type of the second image frame.
ProcessPixelRows<TPixel2, TPixel3>(ImageFrame<TPixel2>, ImageFrame<TPixel3>, PixelAccessorAction<TPixel, TPixel2, TPixel3>)
Execute processPixels
to process pixels of multiple image frames in a safe and efficient manner.
public void ProcessPixelRows<TPixel2, TPixel3>(ImageFrame<TPixel2> frame2, ImageFrame<TPixel3> frame3, PixelAccessorAction<TPixel, TPixel2, TPixel3> processPixels) where TPixel2 : unmanaged, IPixel<TPixel2> where TPixel3 : unmanaged, IPixel<TPixel3>
Parameters
frame2
ImageFrame<TPixel2>The second image frame.
frame3
ImageFrame<TPixel3>The third image frame.
processPixels
PixelAccessorAction<TPixel, TPixel2, TPixel3>The PixelAccessorAction<TPixel1, TPixel2, TPixel3> defining the pixel operations.
Type Parameters
TPixel2
The pixel type of the second image frame.
TPixel3
The pixel type of the third image frame.
ToString()
public override string ToString()