Class ImageFrameCollection<TPixel>
- Namespace
- SixLabors.ImageSharp
- Assembly
- SixLabors.ImageSharp.dll
Encapsulates a pixel-specific collection of ImageFrame<TPixel> instances that make up an Image<TPixel>.
public sealed class ImageFrameCollection<TPixel> : ImageFrameCollection, IDisposable, IEnumerable<ImageFrame>, IEnumerable<ImageFrame<TPixel>>, IEnumerable where TPixel : unmanaged, IPixel<TPixel>
Type Parameters
TPixelThe type of the pixel.
- Inheritance
-
ImageFrameCollection<TPixel>
- Implements
-
IEnumerable<ImageFrame<TPixel>>
- Inherited Members
- Extension Methods
Properties
Count
Gets the number of frames.
public override int Count { get; }
Property Value
this[int]
Gets the ImageFrame<TPixel> at the specified index.
public ImageFrame<TPixel> this[int index] { get; }
Parameters
indexintThe index.
Property Value
- ImageFrame<TPixel>
The ImageFrame<TPixel>.
NonGenericRootFrame
protected override ImageFrame NonGenericRootFrame { get; }
Property Value
RootFrame
Gets the root frame.
public ImageFrame<TPixel> RootFrame { get; }
Property Value
- ImageFrame<TPixel>
Methods
AddFrame(ImageFrame<TPixel>)
Clones the source frame and appends the clone to the end of the collection.
public ImageFrame<TPixel> AddFrame(ImageFrame<TPixel> source)
Parameters
sourceImageFrame<TPixel>The raw pixel data to generate the ImageFrame<TPixel> from.
Returns
- ImageFrame<TPixel>
The cloned ImageFrame<TPixel>.
AddFrame(ReadOnlySpan<TPixel>)
Creates a new frame from the pixel data with the same dimensions as the other frames and inserts the new frame at the end of the collection.
public ImageFrame<TPixel> AddFrame(ReadOnlySpan<TPixel> source)
Parameters
sourceReadOnlySpan<TPixel>The raw pixel data to generate the ImageFrame<TPixel> from.
Returns
- ImageFrame<TPixel>
The new ImageFrame<TPixel>.
AddFrame(TPixel[])
Creates a new frame from the pixel data with the same dimensions as the other frames and inserts the new frame at the end of the collection.
public ImageFrame<TPixel> AddFrame(TPixel[] source)
Parameters
sourceTPixel[]The raw pixel data to generate the ImageFrame<TPixel> from.
Returns
- ImageFrame<TPixel>
The new ImageFrame<TPixel>.
CloneFrame(int)
Creates an Image<TPixel> with only the frame at the specified index with the same metadata as the original image.
public Image<TPixel> CloneFrame(int index)
Parameters
indexintThe zero-based index of the frame to clone.
Returns
- Image<TPixel>
The new Image<TPixel> with the specified frame.
Contains(ImageFrame)
public override bool Contains(ImageFrame frame)
Parameters
frameImageFrame
Returns
Contains(ImageFrame<TPixel>)
Determines whether the ImageFrameCollection<TPixel> contains the frame.
public bool Contains(ImageFrame<TPixel> frame)
Parameters
frameImageFrame<TPixel>The frame.
Returns
- bool
trueif the ImageFrameCollection<TPixel> contains the specified frame; otherwise,false.
CreateFrame()
Creates a new ImageFrame<TPixel> and appends it to the end of the collection.
public ImageFrame<TPixel> CreateFrame()
Returns
- ImageFrame<TPixel>
The new ImageFrame<TPixel>.
CreateFrame(TPixel)
Creates a new ImageFrame<TPixel> and appends it to the end of the collection.
public ImageFrame<TPixel> CreateFrame(TPixel backgroundColor)
Parameters
backgroundColorTPixelThe background color to initialize the pixels with.
Returns
- ImageFrame<TPixel>
The new ImageFrame<TPixel>.
Dispose(bool)
protected override void Dispose(bool disposing)
Parameters
disposingbool
ExportFrame(int)
Removes the frame at the specified index and creates a new image with only the removed frame with the same metadata as the original image.
public Image<TPixel> ExportFrame(int index)
Parameters
indexintThe zero-based index of the frame to export.
Returns
- Image<TPixel>
The new Image<TPixel> with the specified frame.
Exceptions
- InvalidOperationException
Cannot remove last frame.
GetEnumerator()
public IEnumerator<ImageFrame<TPixel>> GetEnumerator()
Returns
- IEnumerator<ImageFrame<TPixel>>
IndexOf(ImageFrame)
public override int IndexOf(ImageFrame frame)
Parameters
frameImageFrame
Returns
IndexOf(ImageFrame<TPixel>)
Determines the index of a specific frame in the ImageFrameCollection<TPixel>.
public int IndexOf(ImageFrame<TPixel> frame)
Parameters
frameImageFrame<TPixel>The ImageFrame<TPixel> to locate in the ImageFrameCollection<TPixel>.
Returns
- int
The index of item if found in the list; otherwise, -1.
InsertFrame(int, ImageFrame<TPixel>)
Clones and inserts the source into the ImageFrameCollection<TPixel> at the specified index.
public ImageFrame<TPixel> InsertFrame(int index, ImageFrame<TPixel> source)
Parameters
indexintThe zero-based index to insert the frame at.
sourceImageFrame<TPixel>The ImageFrame<TPixel> to clone and insert into the ImageFrameCollection<TPixel>.
Returns
- ImageFrame<TPixel>
The cloned ImageFrame<TPixel>.
Exceptions
- ArgumentException
Frame must have the same dimensions as the image.
MoveFrame(int, int)
Moves an ImageFrame<TPixel> from sourceIndex to destinationIndex.
public override void MoveFrame(int sourceIndex, int destinationIndex)
Parameters
sourceIndexintThe zero-based index of the frame to move.
destinationIndexintThe index to move the frame to.
NonGenericAddFrame(ImageFrame)
protected override ImageFrame NonGenericAddFrame(ImageFrame source)
Parameters
sourceImageFrame
Returns
NonGenericCloneFrame(int)
protected override Image NonGenericCloneFrame(int index)
Parameters
indexint
Returns
NonGenericCreateFrame()
protected override ImageFrame NonGenericCreateFrame()
Returns
NonGenericCreateFrame(Color)
protected override ImageFrame NonGenericCreateFrame(Color backgroundColor)
Parameters
backgroundColorColor
Returns
NonGenericExportFrame(int)
protected override Image NonGenericExportFrame(int index)
Parameters
indexint
Returns
NonGenericGetEnumerator()
protected override IEnumerator<ImageFrame> NonGenericGetEnumerator()
Returns
NonGenericGetFrame(int)
protected override ImageFrame NonGenericGetFrame(int index)
Parameters
indexint
Returns
NonGenericInsertFrame(int, ImageFrame)
protected override ImageFrame NonGenericInsertFrame(int index, ImageFrame source)
Parameters
indexintsourceImageFrame
Returns
RemoveFrame(int)
Removes the frame at the specified index and frees all freeable resources associated with it.
public override void RemoveFrame(int index)
Parameters
indexintThe zero-based index of the frame to remove.
Exceptions
- InvalidOperationException
Cannot remove last frame.