Class ImageFrame<TPixel>
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.
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public sealed class ImageFrame<TPixel> : ImageFrame, IConfigurationProvider, IDisposable where TPixel : unmanaged, IPixel<TPixel>
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Properties
| Edit this page View Sourcethis[int, int]
Gets or sets the pixel at the specified position.
Declaration
public TPixel this[int x, int y] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | x | The x-coordinate of the pixel. Must be greater than or equal to zero and less than the width of the image. |
int | 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. |
PixelBuffer
Gets the pixel buffer.
Declaration
public Buffer2D<TPixel> PixelBuffer { get; }
Property Value
Type | Description |
---|---|
Buffer2D<TPixel> |
Methods
| Edit this page View SourceCopyPixelDataTo(Span<byte>)
Copy image pixels to destination
.
Declaration
public void CopyPixelDataTo(Span<byte> destination)
Parameters
Type | Name | Description |
---|---|---|
Span<byte> | destination |
CopyPixelDataTo(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. |
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.
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 |
---|---|
bool | The bool indicating the success. |
Dispose(bool)
Disposes the object and frees resources for the Garbage Collector.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | Whether to dispose of managed and unmanaged objects. |
Overrides
| Edit this page 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>(ImageFrame<TPixel2>, PixelAccessorAction<TPixel, TPixel2>)
Execute processPixels
to process pixels of multiple image frames in a safe and efficient manner.
Declaration
public void ProcessPixelRows<TPixel2>(ImageFrame<TPixel2> frame2, PixelAccessorAction<TPixel, TPixel2> processPixels) where TPixel2 : unmanaged, IPixel<TPixel2>
Parameters
Type | Name | Description |
---|---|---|
ImageFrame<TPixel2> | frame2 | The second image frame. |
PixelAccessorAction<TPixel, TPixel2> | processPixels | The PixelAccessorAction<TPixel1, TPixel2> defining the pixel operations. |
Type Parameters
Name | Description |
---|---|
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.
Declaration
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
Type | Name | Description |
---|---|---|
ImageFrame<TPixel2> | frame2 | The second image frame. |
ImageFrame<TPixel3> | frame3 | The third image frame. |
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 frame. |
TPixel3 | The pixel type of the third image frame. |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |