|
|
|
@ -19,8 +19,7 @@ namespace SixLabors.ImageSharp |
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
|
|
|
public sealed class ImageFrame<TPixel> : IPixelSource<TPixel>, IDisposable |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
where TPixel : struct, IPixel<TPixel> { |
|
|
|
private bool isDisposed; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -30,8 +29,7 @@ namespace SixLabors.ImageSharp |
|
|
|
/// <param name="width">The width of the image in pixels.</param>
|
|
|
|
/// <param name="height">The height of the image in pixels.</param>
|
|
|
|
internal ImageFrame(MemoryManager memoryManager, int width, int height) |
|
|
|
: this(memoryManager, width, height, new ImageFrameMetaData()) |
|
|
|
{ |
|
|
|
: this(memoryManager, width, height, new ImageFrameMetaData()) { |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -59,10 +57,9 @@ namespace SixLabors.ImageSharp |
|
|
|
/// <param name="configuration">The <see cref="Configuration"/> to use for buffer allocation and parallel options to clear the buffer with.</param>
|
|
|
|
/// <param name="width">The width of the image in pixels.</param>
|
|
|
|
/// <param name="height">The height of the image in pixels.</param>
|
|
|
|
/// <param name="clearColor">The color to clear the image with.</param>
|
|
|
|
internal ImageFrame(Configuration configuration, int width, int height, TPixel clearColor) |
|
|
|
: this(configuration, width, height, clearColor, new ImageFrameMetaData()) |
|
|
|
{ |
|
|
|
/// <param name="backgroundColor">The color to clear the image with.</param>
|
|
|
|
internal ImageFrame(Configuration configuration, int width, int height, TPixel backgroundColor) |
|
|
|
: this(configuration, width, height, backgroundColor, new ImageFrameMetaData()) { |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -71,9 +68,9 @@ namespace SixLabors.ImageSharp |
|
|
|
/// <param name="configuration">The <see cref="Configuration"/> to use for buffer allocation and parallel options to clear the buffer with.</param>
|
|
|
|
/// <param name="width">The width of the image in pixels.</param>
|
|
|
|
/// <param name="height">The height of the image in pixels.</param>
|
|
|
|
/// <param name="clearColor">The color to clear the image with.</param>
|
|
|
|
/// <param name="backgroundColor">The color to clear the image with.</param>
|
|
|
|
/// <param name="metaData">The meta data.</param>
|
|
|
|
internal ImageFrame(Configuration configuration, int width, int height, TPixel clearColor, ImageFrameMetaData metaData) |
|
|
|
internal ImageFrame(Configuration configuration, int width, int height, TPixel backgroundColor, ImageFrameMetaData metaData) |
|
|
|
{ |
|
|
|
Guard.NotNull(configuration, nameof(configuration)); |
|
|
|
Guard.MustBeGreaterThan(width, 0, nameof(width)); |
|
|
|
@ -82,7 +79,8 @@ namespace SixLabors.ImageSharp |
|
|
|
|
|
|
|
this.MemoryManager = configuration.MemoryManager; |
|
|
|
this.PixelBuffer = this.MemoryManager.Allocate2D<TPixel>(width, height, false); |
|
|
|
this.Clear(configuration.ParallelOptions, clearColor); |
|
|
|
this.BackgroundColor = backgroundColor; |
|
|
|
this.Clear(configuration.ParallelOptions, backgroundColor); |
|
|
|
this.MetaData = metaData; |
|
|
|
} |
|
|
|
|
|
|
|
@ -93,8 +91,7 @@ namespace SixLabors.ImageSharp |
|
|
|
/// <param name="size">The <see cref="Size"/> of the frame.</param>
|
|
|
|
/// <param name="metaData">The meta data.</param>
|
|
|
|
internal ImageFrame(MemoryManager memoryManager, Size size, ImageFrameMetaData metaData) |
|
|
|
: this(memoryManager, size.Width, size.Height, metaData) |
|
|
|
{ |
|
|
|
: this(memoryManager, size.Width, size.Height, metaData) { |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -133,6 +130,11 @@ namespace SixLabors.ImageSharp |
|
|
|
/// </summary>
|
|
|
|
public int Height => this.PixelBuffer.Height; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the background color.
|
|
|
|
/// </summary>
|
|
|
|
public TPixel BackgroundColor { get; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the meta data of the frame.
|
|
|
|
/// </summary>
|
|
|
|
@ -306,7 +308,7 @@ namespace SixLabors.ImageSharp |
|
|
|
/// </summary>
|
|
|
|
/// <param name="parallelOptions">The parallel options.</param>
|
|
|
|
/// <param name="value">The value to initialize the bitmap with.</param>
|
|
|
|
public void Clear(ParallelOptions parallelOptions, TPixel value) { |
|
|
|
internal void Clear(ParallelOptions parallelOptions, TPixel value) { |
|
|
|
Parallel.For( |
|
|
|
0, |
|
|
|
this.Height, |
|
|
|
|