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
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
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)
Determines whether the ImageFrameCollection<TPixel> contains the frame.
public override bool Contains(ImageFrame frame)
Parameters
frameImageFrameThe frame.
Returns
- bool
trueif 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
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)
Disposes the object and frees resources for the Garbage Collector.
protected override void Dispose(bool disposing)
Parameters
disposingboolWhether 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
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()
Returns an enumerator that iterates through the collection.
public IEnumerator<ImageFrame<TPixel>> GetEnumerator()
Returns
- IEnumerator<ImageFrame<TPixel>>
An enumerator that can be used to iterate through the collection.
IndexOf(ImageFrame)
Determines the index of a specific frame in the ImageFrameCollection.
public override int IndexOf(ImageFrame frame)
Parameters
frameImageFrameThe 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
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)
Implements AddFrame(ImageFrame).
protected override ImageFrame NonGenericAddFrame(ImageFrame source)
Parameters
sourceImageFrameThe frame.
Returns
- ImageFrame
The new frame.
NonGenericCloneFrame(int)
Implements CloneFrame(int).
protected override Image NonGenericCloneFrame(int index)
Parameters
indexintThe 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
backgroundColorColorThe background color.
Returns
- ImageFrame
The new frame.
NonGenericExportFrame(int)
Implements ExportFrame(int).
protected override Image NonGenericExportFrame(int index)
Parameters
indexintThe 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
indexintThe index.
Returns
- ImageFrame
The frame.
NonGenericInsertFrame(int, ImageFrame)
Implements InsertFrame(int, ImageFrame).
protected override ImageFrame NonGenericInsertFrame(int index, ImageFrame source)
Parameters
indexintThe index.
sourceImageFrameThe 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
indexintThe zero-based index of the frame to remove.
Exceptions
- InvalidOperationException
Cannot remove last frame.