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.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public sealed class ImageFrame<TPixel> : ImageFrame, IDisposable where TPixel : struct, IPixel<TPixel>
Type Parameters
Name | Description |
---|---|
TPixel | The pixel format. |
Properties
| Improve this Doc View SourceItem[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. |
PixelBuffer
Declaration
public Buffer2D<TPixel> PixelBuffer { get; }
Property Value
Type | Description |
---|---|
Buffer2D<TPixel> |
Methods
| 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>(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 : struct, 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 : struct, IPixel<TPixel2> where TPixel3 : struct, 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()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |