diff --git a/src/ImageSharp/Image.cs b/src/ImageSharp/Image.cs index def8c575c..772cf6dbe 100644 --- a/src/ImageSharp/Image.cs +++ b/src/ImageSharp/Image.cs @@ -15,17 +15,6 @@ namespace ImageSharp [DebuggerDisplay("Image: {Width}x{Height}")] public class Image : Image { - /// - /// Initializes a new instance of the class. - /// - /// - /// The bootstrapper providing initialization code which allows extending the library. - /// - public Image(Bootstrapper bootstrapper = null) - : base(bootstrapper) - { - } - /// /// Initializes a new instance of the class /// with the height and the width of the image. diff --git a/src/ImageSharp/Image/ImageFrame{TColor}.cs b/src/ImageSharp/Image/ImageFrame{TColor}.cs index fe064c244..aaf775ebb 100644 --- a/src/ImageSharp/Image/ImageFrame{TColor}.cs +++ b/src/ImageSharp/Image/ImageFrame{TColor}.cs @@ -19,11 +19,13 @@ namespace ImageSharp /// /// Initializes a new instance of the class. /// + /// The width of the image in pixels. + /// The height of the image in pixels. /// /// The bootstrapper providing initialization code which allows extending the library. /// - public ImageFrame(Bootstrapper bootstrapper = null) - : base(bootstrapper) + public ImageFrame(int width, int height, Bootstrapper bootstrapper = null) + : base(width, height, bootstrapper) { } @@ -53,14 +55,12 @@ namespace ImageSharp { scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction(scaleFunc); - ImageFrame target = new ImageFrame(this.Bootstrapper) + ImageFrame target = new ImageFrame(this.Width, this.Height, this.Bootstrapper) { Quality = this.Quality, FrameDelay = this.FrameDelay }; - target.InitPixels(this.Width, this.Height); - using (PixelAccessor pixels = this.Lock()) using (PixelAccessor targetPixels = target.Lock()) { diff --git a/src/ImageSharp/Image/Image{TColor}.cs b/src/ImageSharp/Image/Image{TColor}.cs index c60585ab3..84fb39a0c 100644 --- a/src/ImageSharp/Image/Image{TColor}.cs +++ b/src/ImageSharp/Image/Image{TColor}.cs @@ -37,19 +37,6 @@ namespace ImageSharp /// public const double DefaultVerticalResolution = 96; - /// - /// Initializes a new instance of the class. - /// - /// - /// The bootstrapper providing initialization code which allows extending the library. - /// - public Image(Bootstrapper bootstrapper = null) - : base(bootstrapper) - { - // We want to throw here. - this.CurrentImageFormat = this.Bootstrapper.ImageFormats.First(); - } - /// /// Initializes a new instance of the class /// with the height and the width of the image. @@ -391,7 +378,7 @@ namespace ImageSharp { if (!this.Bootstrapper.ImageFormats.Any()) { - return; + throw new NotSupportedException("No image formats have been configured."); } if (!stream.CanRead) diff --git a/src/ImageSharp/ImageFrame.cs b/src/ImageSharp/ImageFrame.cs index 3ce264f38..66a2049e8 100644 --- a/src/ImageSharp/ImageFrame.cs +++ b/src/ImageSharp/ImageFrame.cs @@ -16,7 +16,13 @@ namespace ImageSharp /// /// Initializes a new instance of the class. /// - public ImageFrame() + /// The width of the image in pixels. + /// The height of the image in pixels. + /// + /// The bootstrapper providing initialization code which allows extending the library. + /// + public ImageFrame(int width, int height, Bootstrapper bootstrapper = null) + : base(width, height, bootstrapper) { } diff --git a/src/ImageSharp/Quantizers/QuantizedImage.cs b/src/ImageSharp/Quantizers/QuantizedImage.cs index 6b78ce801..4f2c4b149 100644 --- a/src/ImageSharp/Quantizers/QuantizedImage.cs +++ b/src/ImageSharp/Quantizers/QuantizedImage.cs @@ -68,7 +68,7 @@ namespace ImageSharp.Quantizers /// public Image ToImage() { - Image image = new Image(); + Image image = new Image(this.Width, this.Height); int pixelCount = this.Pixels.Length; int palleteCount = this.Palette.Length - 1; diff --git a/tests/ImageSharp.Tests/TestBase.cs b/tests/ImageSharp.Tests/TestBase.cs index a7732972e..8a83746e7 100644 --- a/tests/ImageSharp.Tests/TestBase.cs +++ b/tests/ImageSharp.Tests/TestBase.cs @@ -15,9 +15,9 @@ namespace ImageSharp.Tests public abstract class TestBase { /// - /// Initializes a new instance of the class. + /// Initializes static members of the class. /// - protected TestBase() + static TestBase() { // Register the individual image formats. Bootstrapper.Default.AddImageFormat(new PngFormat()); diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index 892e344d6..4237fdb51 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -39,7 +39,7 @@ namespace ImageSharp.Tests { return Path.Combine(FormatsDirectory, file); } - + public static TestFile Create(string file) { return cache.GetOrAdd(file, (string fileName) => diff --git a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs index 547efaa6f..489ef970a 100644 --- a/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs +++ b/tests/ImageSharp.Tests/TestUtilities/PixelTypes.cs @@ -54,10 +54,10 @@ namespace ImageSharp.Tests /// Triggers instantiating the subclass of /// StandardImageClass = 1 << 29, - + // TODO: Add multi-flag entries by rules defined in PackedPixelConverterHelper // "All" is handled as a separate, individual case instead of using bitwise OR - All = 30 + All = 30 } } \ No newline at end of file