Class ImageFrameCollection
- Namespace
- SixLabors.ImageSharp
- Assembly
- SixLabors.ImageSharp.dll
Encapsulates a pixel-agnostic collection of ImageFrame instances that make up an Image.
public abstract class ImageFrameCollection : IDisposable, IEnumerable<ImageFrame>, IEnumerable
- Inheritance
-
ImageFrameCollection
- Implements
- Derived
-
ImageFrameCollection<TPixel>
- Inherited Members
Constructors
ImageFrameCollection()
protected ImageFrameCollection()
Properties
Count
Gets the number of frames.
public abstract int Count { get; }
Property Value
this[int]
Gets the ImageFrame at the specified index.
public ImageFrame this[int index] { get; }
Parameters
index
intThe index.
Property Value
- ImageFrame
The ImageFrame.
NonGenericRootFrame
Gets the root frame. (Implements RootFrame.)
protected abstract ImageFrame NonGenericRootFrame { get; }
Property Value
RootFrame
Gets the root frame.
public ImageFrame RootFrame { get; }
Property Value
Methods
AddFrame(ImageFrame)
Clones the source
frame and appends the clone to the end of the collection.
public ImageFrame AddFrame(ImageFrame source)
Parameters
source
ImageFrameThe raw pixel data to generate the ImageFrame<TPixel> from.
Returns
- ImageFrame
The cloned 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 CloneFrame(int index)
Parameters
index
intThe zero-based index of the frame to clone.
Returns
- Image
The new Image<TPixel> with the specified frame.
Contains(ImageFrame)
Determines whether the ImageFrameCollection<TPixel> contains the frame
.
public abstract bool Contains(ImageFrame frame)
Parameters
frame
ImageFrameThe 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 CreateFrame()
Returns
- ImageFrame
The new ImageFrame<TPixel>.
CreateFrame(Color)
Creates a new ImageFrame<TPixel> and appends it to the end of the collection.
public ImageFrame CreateFrame(Color backgroundColor)
Parameters
backgroundColor
ColorThe background color to initialize the pixels with.
Returns
- ImageFrame
The new ImageFrame<TPixel>.
Dispose()
public void Dispose()
Dispose(bool)
Disposes the object and frees resources for the Garbage Collector.
protected abstract void Dispose(bool disposing)
Parameters
disposing
boolWhether to dispose of managed and unmanaged objects.
EnsureNotDisposed()
Throws ObjectDisposedException if the image frame is disposed.
protected void EnsureNotDisposed()
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 ExportFrame(int index)
Parameters
index
intThe zero-based index of the frame to export.
Returns
- Image
The new Image<TPixel> with the specified frame.
Exceptions
- InvalidOperationException
Cannot remove last frame.
IndexOf(ImageFrame)
Determines the index of a specific frame
in the ImageFrameCollection.
public abstract 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.
InsertFrame(int, ImageFrame)
Clones and inserts the source
into the ImageFrameCollection at the specified index
.
public ImageFrame InsertFrame(int index, ImageFrame source)
Parameters
index
intThe zero-based index to insert the frame at.
source
ImageFrameThe ImageFrame to clone and insert into the ImageFrameCollection.
Returns
- ImageFrame
The cloned ImageFrame.
Exceptions
- ArgumentException
Frame must have the same dimensions as the image.
MoveFrame(int, int)
Moves an ImageFrame<TPixel> from sourceIndex
to destinationIndex
.
public abstract 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 abstract ImageFrame NonGenericAddFrame(ImageFrame source)
Parameters
source
ImageFrameThe frame.
Returns
- ImageFrame
The new frame.
NonGenericCloneFrame(int)
Implements CloneFrame(int).
protected abstract Image NonGenericCloneFrame(int index)
Parameters
index
intThe index.
Returns
- Image
The new image.
NonGenericCreateFrame()
Implements CreateFrame().
protected abstract ImageFrame NonGenericCreateFrame()
Returns
- ImageFrame
The new frame.
NonGenericCreateFrame(Color)
Implements CreateFrame().
protected abstract ImageFrame NonGenericCreateFrame(Color backgroundColor)
Parameters
backgroundColor
ColorThe background color.
Returns
- ImageFrame
The new frame.
NonGenericExportFrame(int)
Implements ExportFrame(int).
protected abstract Image NonGenericExportFrame(int index)
Parameters
index
intThe index.
Returns
- Image
The new image.
NonGenericGetEnumerator()
Implements GetEnumerator().
protected abstract IEnumerator<ImageFrame> NonGenericGetEnumerator()
Returns
- IEnumerator<ImageFrame>
The enumerator.
NonGenericGetFrame(int)
Implements the getter of the indexer.
protected abstract ImageFrame NonGenericGetFrame(int index)
Parameters
index
intThe index.
Returns
- ImageFrame
The frame.
NonGenericInsertFrame(int, ImageFrame)
Implements InsertFrame(int, ImageFrame).
protected abstract 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 abstract void RemoveFrame(int index)
Parameters
index
intThe zero-based index of the frame to remove.
Exceptions
- InvalidOperationException
Cannot remove last frame.