diff --git a/src/ImageSharp/IImageFrameCollection.cs b/src/ImageSharp/IImageFrameCollection.cs
deleted file mode 100644
index 59c64a6af6..0000000000
--- a/src/ImageSharp/IImageFrameCollection.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-// Copyright (c) Six Labors and contributors.
-// Licensed under the Apache License, Version 2.0.
-
-using System;
-using System.Collections.Generic;
-
-using SixLabors.ImageSharp.PixelFormats;
-
-namespace SixLabors.ImageSharp
-{
- ///
- /// Encapsulates a collection of instances that make up an .
- ///
- /// The type of the pixel.
- public interface IImageFrameCollection : IEnumerable>
- where TPixel : struct, IPixel
- {
- ///
- /// Gets the number of frames.
- ///
- int Count { get; }
-
- ///
- /// Gets the root frame.
- ///
- ImageFrame RootFrame { get; }
-
- ///
- /// Gets the at the specified index.
- ///
- ///
- /// The .
- ///
- /// The index.
- /// The at the specified index.
- ImageFrame this[int index] { get; }
-
- ///
- /// Creates an with only the frame at the specified index
- /// with the same metadata as the original image.
- ///
- /// The zero-based index of the frame to clone.
- /// The new with the specified frame.
- Image CloneFrame(int index);
-
- ///
- /// 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.
- ///
- /// The zero-based index of the frame to export.
- /// Cannot remove last frame.
- /// The new with the specified frame.
- Image ExportFrame(int index);
-
- ///
- /// Removes the frame at the specified index and frees all freeable resources associated with it.
- ///
- /// The zero-based index of the frame to remove.
- /// Cannot remove last frame.
- void RemoveFrame(int index);
-
- ///
- /// Creates a new and appends it to the end of the collection.
- ///
- /// The new .
- ImageFrame CreateFrame();
-
- ///
- /// Clones the frame and appends the clone to the end of the collection.
- ///
- /// The raw pixel data to generate the from.
- /// The cloned .
- ImageFrame AddFrame(ImageFrame source);
-
- ///
- /// 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.
- ///
- /// The raw pixel data to generate the from.
- /// The new .
- ImageFrame AddFrame(TPixel[] source);
-
- ///
- /// Clones and inserts the into the at the specified .
- ///
- /// The zero-based index to insert the frame at.
- /// The to clone and insert into the .
- /// Frame must have the same dimensions as the image.
- /// The cloned .
- ImageFrame InsertFrame(int index, ImageFrame source);
-
- ///
- /// Moves an from to .
- ///
- /// The zero-based index of the frame to move.
- /// The index to move the frame to.
- void MoveFrame(int sourceIndex, int destinationIndex);
-
- ///
- /// Determines the index of a specific in the .
- ///
- /// The to locate in the .
- /// The index of item if found in the list; otherwise, -1.
- int IndexOf(ImageFrame frame);
-
- ///
- /// Determines whether the contains the .
- ///
- /// The frame.
- ///
- /// true if the contains the specified frame; otherwise, false.
- ///
- bool Contains(ImageFrame frame);
- }
-}
\ No newline at end of file
diff --git a/src/ImageSharp/ImageFrameCollection.cs b/src/ImageSharp/ImageFrameCollection.cs
index eb118979c8..97a8df875d 100644
--- a/src/ImageSharp/ImageFrameCollection.cs
+++ b/src/ImageSharp/ImageFrameCollection.cs
@@ -9,8 +9,11 @@ using SixLabors.ImageSharp.PixelFormats;
namespace SixLabors.ImageSharp
{
- ///
- internal sealed class ImageFrameCollection : IImageFrameCollection
+ ///
+ /// Encapsulates a collection of instances that make up an .
+ ///
+ /// The type of the pixel.
+ public sealed class ImageFrameCollection : IEnumerable>
where TPixel : struct, IPixel
{
private readonly IList> frames = new List>();
@@ -41,51 +44,85 @@ namespace SixLabors.ImageSharp
}
}
- ///
+ ///
+ /// Gets the number of frames.
+ ///
public int Count => this.frames.Count;
- ///
+ ///
+ /// Gets the root frame.
+ ///
public ImageFrame RootFrame => this.frames.Count > 0 ? this.frames[0] : null;
- ///
+ ///
+ /// Gets the at the specified index.
+ ///
+ ///
+ /// The .
+ ///
+ /// The index.
+ /// The at the specified index.
public ImageFrame this[int index] => this.frames[index];
- ///
+ ///
+ /// Determines the index of a specific in the .
+ ///
+ /// The to locate in the .
+ /// The index of item if found in the list; otherwise, -1.
public int IndexOf(ImageFrame frame) => this.frames.IndexOf(frame);
- ///
- public ImageFrame InsertFrame(int index, ImageFrame frame)
+ ///
+ /// Clones and inserts the into the at the specified .
+ ///
+ /// The zero-based index to insert the frame at.
+ /// The to clone and insert into the .
+ /// Frame must have the same dimensions as the image.
+ /// The cloned .
+ public ImageFrame InsertFrame(int index, ImageFrame source)
{
- this.ValidateFrame(frame);
- ImageFrame clonedFrame = frame.Clone();
+ this.ValidateFrame(source);
+ ImageFrame clonedFrame = source.Clone();
this.frames.Insert(index, clonedFrame);
return clonedFrame;
}
- ///
- public ImageFrame AddFrame(ImageFrame frame)
+ ///
+ /// Clones the frame and appends the clone to the end of the collection.
+ ///
+ /// The raw pixel data to generate the from.
+ /// The cloned .
+ public ImageFrame AddFrame(ImageFrame source)
{
- this.ValidateFrame(frame);
- ImageFrame clonedFrame = frame.Clone();
+ this.ValidateFrame(source);
+ ImageFrame clonedFrame = source.Clone();
this.frames.Add(clonedFrame);
return clonedFrame;
}
- ///
- public ImageFrame AddFrame(TPixel[] data)
+ ///
+ /// 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.
+ ///
+ /// The raw pixel data to generate the from.
+ /// The new .
+ public ImageFrame AddFrame(TPixel[] source)
{
- Guard.NotNull(data, nameof(data));
+ Guard.NotNull(source, nameof(source));
var frame = ImageFrame.LoadPixelData(
this.parent.GetMemoryManager(),
- new Span(data),
+ new Span(source),
this.RootFrame.Width,
this.RootFrame.Height);
this.frames.Add(frame);
return frame;
}
- ///
+ ///
+ /// Removes the frame at the specified index and frees all freeable resources associated with it.
+ ///
+ /// The zero-based index of the frame to remove.
+ /// Cannot remove last frame.
public void RemoveFrame(int index)
{
if (index == 0 && this.Count == 1)
@@ -98,26 +135,42 @@ namespace SixLabors.ImageSharp
frame.Dispose();
}
- ///
+ ///
+ /// Determines whether the contains the .
+ ///
+ /// The frame.
+ ///
+ /// true if the contains the specified frame; otherwise, false.
+ ///
public bool Contains(ImageFrame frame)
{
return this.frames.Contains(frame);
}
- ///
- public void MoveFrame(int sourceIndex, int destIndex)
+ ///
+ /// Moves an from to .
+ ///
+ /// The zero-based index of the frame to move.
+ /// The index to move the frame to.
+ public void MoveFrame(int sourceIndex, int destinationIndex)
{
- if (sourceIndex == destIndex)
+ if (sourceIndex == destinationIndex)
{
return;
}
ImageFrame frameAtIndex = this.frames[sourceIndex];
this.frames.RemoveAt(sourceIndex);
- this.frames.Insert(destIndex, frameAtIndex);
+ this.frames.Insert(destinationIndex, frameAtIndex);
}
- ///
+ ///
+ /// 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.
+ ///
+ /// The zero-based index of the frame to export.
+ /// Cannot remove last frame.
+ /// The new with the specified frame.
public Image ExportFrame(int index)
{
ImageFrame frame = this[index];
@@ -132,7 +185,12 @@ namespace SixLabors.ImageSharp
return new Image(this.parent.GetConfiguration(), this.parent.MetaData.Clone(), new[] { frame });
}
- ///
+ ///
+ /// Creates an with only the frame at the specified index
+ /// with the same metadata as the original image.
+ ///
+ /// The zero-based index of the frame to clone.
+ /// The new with the specified frame.
public Image CloneFrame(int index)
{
ImageFrame frame = this[index];
@@ -140,10 +198,15 @@ namespace SixLabors.ImageSharp
return new Image(this.parent.GetConfiguration(), this.parent.MetaData.Clone(), new[] { clonedFrame });
}
- ///
- public ImageFrame CreateFrame()
- {
- var frame = new ImageFrame(this.parent.GetConfiguration(), this.RootFrame.Width, this.RootFrame.Height, default);
+ ///
+ /// Creates a new and appends it to the end of the collection.
+ ///
+ /// The background color to initialize the pixels with.
+ ///
+ /// The new .
+ ///
+ public ImageFrame CreateFrame(TPixel backgroundColor = default) {
+ var frame = new ImageFrame(this.parent.GetConfiguration(), this.RootFrame.Width, this.RootFrame.Height, backgroundColor);
this.frames.Add(frame);
return frame;
}
diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs
index 2d98696028..596dc9bcd0 100644
--- a/src/ImageSharp/Image{TPixel}.cs
+++ b/src/ImageSharp/Image{TPixel}.cs
@@ -135,7 +135,7 @@ namespace SixLabors.ImageSharp
///
/// Gets the frames.
///
- public IImageFrameCollection Frames => this.frames;
+ public ImageFrameCollection Frames => this.frames;
///
/// Gets the root frame.