Class ImageFrameCollection<TPixel>
Encapsulates a pixel-specific collection of ImageFrame<TPixel> instances that make up an Image<TPixel>.
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public sealed class ImageFrameCollection<TPixel> : ImageFrameCollection, IDisposable, IEnumerable<ImageFrame>, IEnumerable<ImageFrame<TPixel>>, IEnumerable where TPixel : unmanaged, IPixel<TPixel>
Type Parameters
Name | Description |
---|---|
TPixel | The type of the pixel. |
Properties
| Edit this page View SourceCount
Gets the number of frames.
Declaration
public override int Count { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
| Edit this page View Sourcethis[int]
Gets the ImageFrame<TPixel> at the specified index.
Declaration
public ImageFrame<TPixel> this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
Property Value
Type | Description |
---|---|
ImageFrame<TPixel> | The ImageFrame<TPixel>. |
NonGenericRootFrame
Gets the root frame. (Implements RootFrame.)
Declaration
protected override ImageFrame NonGenericRootFrame { get; }
Property Value
Type | Description |
---|---|
ImageFrame |
Overrides
| Edit this page View SourceRootFrame
Gets the root frame.
Declaration
public ImageFrame<TPixel> RootFrame { get; }
Property Value
Type | Description |
---|---|
ImageFrame<TPixel> |
Methods
| Edit this page View SourceAddFrame(ImageFrame<TPixel>)
Clones the source
frame and appends the clone to the end of the collection.
Declaration
public ImageFrame<TPixel> AddFrame(ImageFrame<TPixel> source)
Parameters
Type | Name | Description |
---|---|---|
ImageFrame<TPixel> | source | The raw pixel data to generate the ImageFrame<TPixel> from. |
Returns
Type | Description |
---|---|
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.
Declaration
public ImageFrame<TPixel> AddFrame(ReadOnlySpan<TPixel> source)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<TPixel> | source | The raw pixel data to generate the ImageFrame<TPixel> from. |
Returns
Type | Description |
---|---|
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.
Declaration
public ImageFrame<TPixel> AddFrame(TPixel[] source)
Parameters
Type | Name | Description |
---|---|---|
TPixel[] | source | The raw pixel data to generate the ImageFrame<TPixel> from. |
Returns
Type | Description |
---|---|
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.
Declaration
public Image<TPixel> CloneFrame(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the frame to clone. |
Returns
Type | Description |
---|---|
Image<TPixel> | The new Image<TPixel> with the specified frame. |
Contains(ImageFrame)
Determines whether the ImageFrameCollection<TPixel> contains the frame
.
Declaration
public override bool Contains(ImageFrame frame)
Parameters
Type | Name | Description |
---|---|---|
ImageFrame | frame | The frame. |
Returns
Type | Description |
---|---|
bool |
|
Overrides
| Edit this page View SourceContains(ImageFrame<TPixel>)
Determines whether the ImageFrameCollection<TPixel> contains the frame
.
Declaration
public bool Contains(ImageFrame<TPixel> frame)
Parameters
Type | Name | Description |
---|---|---|
ImageFrame<TPixel> | frame | The frame. |
Returns
Type | Description |
---|---|
bool |
|
CreateFrame()
Creates a new ImageFrame<TPixel> and appends it to the end of the collection.
Declaration
public ImageFrame<TPixel> CreateFrame()
Returns
Type | Description |
---|---|
ImageFrame<TPixel> | The new ImageFrame<TPixel>. |
CreateFrame(TPixel)
Creates a new ImageFrame<TPixel> and appends it to the end of the collection.
Declaration
public ImageFrame<TPixel> CreateFrame(TPixel backgroundColor)
Parameters
Type | Name | Description |
---|---|---|
TPixel | backgroundColor | The background color to initialize the pixels with. |
Returns
Type | Description |
---|---|
ImageFrame<TPixel> | The new ImageFrame<TPixel>. |
Dispose(bool)
Disposes the object and frees resources for the Garbage Collector.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | Whether to dispose of managed and unmanaged objects. |
Overrides
| Edit this page View SourceExportFrame(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.
Declaration
public Image<TPixel> ExportFrame(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the frame to export. |
Returns
Type | Description |
---|---|
Image<TPixel> | The new Image<TPixel> with the specified frame. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Cannot remove last frame. |
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public IEnumerator<ImageFrame<TPixel>> GetEnumerator()
Returns
Type | Description |
---|---|
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.
Declaration
public override int IndexOf(ImageFrame frame)
Parameters
Type | Name | Description |
---|---|---|
ImageFrame | frame | The ImageFrame to locate in the ImageFrameCollection. |
Returns
Type | Description |
---|---|
int | The index of item if found in the list; otherwise, -1. |
Overrides
| Edit this page View SourceIndexOf(ImageFrame<TPixel>)
Determines the index of a specific frame
in the ImageFrameCollection<TPixel>.
Declaration
public int IndexOf(ImageFrame<TPixel> frame)
Parameters
Type | Name | Description |
---|---|---|
ImageFrame<TPixel> | frame | The ImageFrame<TPixel> to locate in the ImageFrameCollection<TPixel>. |
Returns
Type | Description |
---|---|
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
.
Declaration
public ImageFrame<TPixel> InsertFrame(int index, ImageFrame<TPixel> source)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index to insert the frame at. |
ImageFrame<TPixel> | source | The ImageFrame<TPixel> to clone and insert into the ImageFrameCollection<TPixel>. |
Returns
Type | Description |
---|---|
ImageFrame<TPixel> | The cloned ImageFrame<TPixel>. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Frame must have the same dimensions as the image. |
MoveFrame(int, int)
Moves an ImageFrame<TPixel> from sourceIndex
to destinationIndex
.
Declaration
public override void MoveFrame(int sourceIndex, int destinationIndex)
Parameters
Type | Name | Description |
---|---|---|
int | sourceIndex | The zero-based index of the frame to move. |
int | destinationIndex | The index to move the frame to. |
Overrides
| Edit this page View SourceNonGenericAddFrame(ImageFrame)
Implements AddFrame(ImageFrame).
Declaration
protected override ImageFrame NonGenericAddFrame(ImageFrame source)
Parameters
Type | Name | Description |
---|---|---|
ImageFrame | source | The frame. |
Returns
Type | Description |
---|---|
ImageFrame | The new frame. |
Overrides
| Edit this page View SourceNonGenericCloneFrame(int)
Implements CloneFrame(int).
Declaration
protected override Image NonGenericCloneFrame(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
Returns
Type | Description |
---|---|
Image | The new image. |
Overrides
| Edit this page View SourceNonGenericCreateFrame()
Implements CreateFrame().
Declaration
protected override ImageFrame NonGenericCreateFrame()
Returns
Type | Description |
---|---|
ImageFrame | The new frame. |
Overrides
| Edit this page View SourceNonGenericCreateFrame(Color)
Implements CreateFrame().
Declaration
protected override ImageFrame NonGenericCreateFrame(Color backgroundColor)
Parameters
Type | Name | Description |
---|---|---|
Color | backgroundColor | The background color. |
Returns
Type | Description |
---|---|
ImageFrame | The new frame. |
Overrides
| Edit this page View SourceNonGenericExportFrame(int)
Implements ExportFrame(int).
Declaration
protected override Image NonGenericExportFrame(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
Returns
Type | Description |
---|---|
Image | The new image. |
Overrides
| Edit this page View SourceNonGenericGetEnumerator()
Implements GetEnumerator().
Declaration
protected override IEnumerator<ImageFrame> NonGenericGetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<ImageFrame> | The enumerator. |
Overrides
| Edit this page View SourceNonGenericGetFrame(int)
Implements the getter of the indexer.
Declaration
protected override ImageFrame NonGenericGetFrame(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
Returns
Type | Description |
---|---|
ImageFrame | The frame. |
Overrides
| Edit this page View SourceNonGenericInsertFrame(int, ImageFrame)
Implements InsertFrame(int, ImageFrame).
Declaration
protected override ImageFrame NonGenericInsertFrame(int index, ImageFrame source)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index. |
ImageFrame | source | The frame. |
Returns
Type | Description |
---|---|
ImageFrame | The new frame. |
Overrides
| Edit this page View SourceRemoveFrame(int)
Removes the frame at the specified index and frees all freeable resources associated with it.
Declaration
public override void RemoveFrame(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The zero-based index of the frame to remove. |
Overrides
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Cannot remove last frame. |