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
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)
public override bool Contains(ImageFrame frame)
Parameters
frame
ImageFrame
Returns
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)
protected override void Dispose(bool disposing)
Parameters
disposing
bool
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)
public override int IndexOf(ImageFrame frame)
Parameters
frame
ImageFrame
Returns
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)
protected override ImageFrame NonGenericAddFrame(ImageFrame source)
Parameters
source
ImageFrame
Returns
NonGenericCloneFrame(int)
protected override Image NonGenericCloneFrame(int index)
Parameters
index
int
Returns
NonGenericCreateFrame()
protected override ImageFrame NonGenericCreateFrame()
Returns
NonGenericCreateFrame(Color)
protected override ImageFrame NonGenericCreateFrame(Color backgroundColor)
Parameters
backgroundColor
Color
Returns
NonGenericExportFrame(int)
protected override Image NonGenericExportFrame(int index)
Parameters
index
int
Returns
NonGenericGetEnumerator()
protected override IEnumerator<ImageFrame> NonGenericGetEnumerator()
Returns
NonGenericGetFrame(int)
protected override ImageFrame NonGenericGetFrame(int index)
Parameters
index
int
Returns
NonGenericInsertFrame(int, ImageFrame)
protected override ImageFrame NonGenericInsertFrame(int index, ImageFrame source)
Parameters
index
intsource
ImageFrame
Returns
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.