Browse Source

Use RootFrame for validation

pull/326/head
James Jackson-South 9 years ago
parent
commit
40433d8fea
  1. 10
      src/ImageSharp/Image/ImageFrameCollection.cs
  2. 12
      src/ImageSharp/Image/Image{TPixel}.cs

10
src/ImageSharp/Image/ImageFrameCollection.cs

@ -17,14 +17,6 @@ namespace SixLabors.ImageSharp
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
private readonly IList<ImageFrame<TPixel>> frames = new List<ImageFrame<TPixel>>(); private readonly IList<ImageFrame<TPixel>> frames = new List<ImageFrame<TPixel>>();
private readonly int parentWidth;
private readonly int parentHeight;
internal ImageFrameCollection(Image<TPixel> parent)
{
this.parentWidth = parent.Width;
this.parentHeight = parent.Height;
}
/// <summary> /// <summary>
/// Gets the count. /// Gets the count.
@ -103,7 +95,7 @@ namespace SixLabors.ImageSharp
{ {
if (this.Count != 0) if (this.Count != 0)
{ {
if (this.parentWidth != frame.Width || this.parentHeight != frame.Height) if (this.RootFrame.Width != frame.Width || this.RootFrame.Height != frame.Height)
{ {
throw new ArgumentException("Frame must have the same dimensions as the image", nameof(frame)); throw new ArgumentException("Frame must have the same dimensions as the image", nameof(frame));
} }

12
src/ImageSharp/Image/Image{TPixel}.cs

@ -1,22 +1,14 @@
// Copyright (c) Six Labors and contributors. // Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0. // Licensed under the Apache License, Version 2.0.
using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats; using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.MetaData; using SixLabors.ImageSharp.MetaData;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp namespace SixLabors.ImageSharp
{ {
@ -81,7 +73,7 @@ namespace SixLabors.ImageSharp
this.ImageConfiguration = configuration ?? Configuration.Default; this.ImageConfiguration = configuration ?? Configuration.Default;
this.MetaData = metadata ?? new ImageMetaData(); this.MetaData = metadata ?? new ImageMetaData();
this.Frames = new ImageFrameCollection<TPixel>(this); this.Frames = new ImageFrameCollection<TPixel>();
if (frames != null) if (frames != null)
{ {

Loading…
Cancel
Save