Table of Contents

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
Inherited Members

Constructors

ImageFrameCollection()

protected ImageFrameCollection()

Properties

Count

Gets the number of frames.

public abstract int Count { get; }

Property Value

int

this[int]

Gets the ImageFrame at the specified index.

public ImageFrame this[int index] { get; }

Parameters

index int

The index.

Property Value

ImageFrame

The ImageFrame.

NonGenericRootFrame

Gets the root frame. (Implements RootFrame.)

protected abstract ImageFrame NonGenericRootFrame { get; }

Property Value

ImageFrame

RootFrame

Gets the root frame.

public ImageFrame RootFrame { get; }

Property Value

ImageFrame

Methods

AddFrame(ImageFrame)

Clones the source frame and appends the clone to the end of the collection.

public ImageFrame AddFrame(ImageFrame source)

Parameters

source ImageFrame

The 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 int

The 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 ImageFrame

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 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 Color

The 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 bool

Whether 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 int

The 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 ImageFrame

The 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 int

The zero-based index to insert the frame at.

source ImageFrame

The 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 int

The zero-based index of the frame to move.

destinationIndex int

The index to move the frame to.

NonGenericAddFrame(ImageFrame)

protected abstract ImageFrame NonGenericAddFrame(ImageFrame source)

Parameters

source ImageFrame

The frame.

Returns

ImageFrame

The new frame.

NonGenericCloneFrame(int)

Implements CloneFrame(int).

protected abstract Image NonGenericCloneFrame(int index)

Parameters

index int

The 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 Color

The background color.

Returns

ImageFrame

The new frame.

NonGenericExportFrame(int)

Implements ExportFrame(int).

protected abstract Image NonGenericExportFrame(int index)

Parameters

index int

The 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 int

The index.

Returns

ImageFrame

The frame.

NonGenericInsertFrame(int, ImageFrame)

protected abstract ImageFrame NonGenericInsertFrame(int index, ImageFrame source)

Parameters

index int

The index.

source ImageFrame

The 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 int

The zero-based index of the frame to remove.

Exceptions

InvalidOperationException

Cannot remove last frame.