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
TPixel
The 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
index
intThe index.
Property Value
- ImageFrame<TPixel>
The ImageFrame<TPixel>.
NonGenericRootFrame
Gets the root frame. (Implements RootFrame.)
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
source
ImageFrame<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
source
ReadOnlySpan<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
source
TPixel[]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
index
intThe zero-based index of the frame to clone.
Returns
- Image<TPixel>
The new Image<TPixel> with the specified frame.
Contains(ImageFrame)
Determines whether the ImageFrameCollection<TPixel> contains the frame
.
public override bool Contains(ImageFrame frame)
Parameters
frame
ImageFrameThe frame.
Returns
- bool
true
if the ImageFrameCollection<TPixel> contains the specified frame; otherwise,false
.
Contains(ImageFrame<TPixel>)
Determines whether the ImageFrameCollection<TPixel> contains the frame
.
public bool Contains(ImageFrame<TPixel> frame)
Parameters
frame
ImageFrame<TPixel>The frame.
Returns
- bool
true
if 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
backgroundColor
TPixelThe background color to initialize the pixels with.
Returns
- ImageFrame<TPixel>
The new ImageFrame<TPixel>.
Dispose(bool)
Disposes the object and frees resources for the Garbage Collector.
protected override void Dispose(bool disposing)
Parameters
disposing
boolWhether to dispose of managed and unmanaged objects.
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
index
intThe 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)
Determines the index of a specific frame
in the ImageFrameCollection.
public override int IndexOf(ImageFrame frame)
Parameters
frame
ImageFrameThe ImageFrame to locate in the ImageFrameCollection.
Returns
- int
The index of item if found in the list; otherwise, -1.
IndexOf(ImageFrame<TPixel>)
Determines the index of a specific frame
in the ImageFrameCollection<TPixel>.
public int IndexOf(ImageFrame<TPixel> frame)
Parameters
frame
ImageFrame<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
index
intThe zero-based index to insert the frame at.
source
ImageFrame<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
sourceIndex
intThe zero-based index of the frame to move.
destinationIndex
intThe index to move the frame to.
NonGenericAddFrame(ImageFrame)
Implements AddFrame(ImageFrame).
protected override ImageFrame NonGenericAddFrame(ImageFrame source)
Parameters
source
ImageFrameThe frame.
Returns
- ImageFrame
The new frame.
NonGenericCloneFrame(int)
Implements CloneFrame(int).
protected override Image NonGenericCloneFrame(int index)
Parameters
index
intThe index.
Returns
- Image
The new image.
NonGenericCreateFrame()
Implements CreateFrame().
protected override ImageFrame NonGenericCreateFrame()
Returns
- ImageFrame
The new frame.
NonGenericCreateFrame(Color)
Implements CreateFrame().
protected override ImageFrame NonGenericCreateFrame(Color backgroundColor)
Parameters
backgroundColor
ColorThe background color.
Returns
- ImageFrame
The new frame.
NonGenericExportFrame(int)
Implements ExportFrame(int).
protected override Image NonGenericExportFrame(int index)
Parameters
index
intThe index.
Returns
- Image
The new image.
NonGenericGetEnumerator()
Implements GetEnumerator().
protected override IEnumerator<ImageFrame> NonGenericGetEnumerator()
Returns
- IEnumerator<ImageFrame>
The enumerator.
NonGenericGetFrame(int)
Implements the getter of the indexer.
protected override ImageFrame NonGenericGetFrame(int index)
Parameters
index
intThe index.
Returns
- ImageFrame
The frame.
NonGenericInsertFrame(int, ImageFrame)
Implements InsertFrame(int, ImageFrame).
protected override ImageFrame NonGenericInsertFrame(int index, ImageFrame source)
Parameters
index
intThe index.
source
ImageFrameThe frame.
Returns
- ImageFrame
The new frame.
RemoveFrame(int)
Removes the frame at the specified index and frees all freeable resources associated with it.
public override void RemoveFrame(int index)
Parameters
index
intThe zero-based index of the frame to remove.
Exceptions
- InvalidOperationException
Cannot remove last frame.