Browse Source

move Configuration to be fist paramater.

Configureatino should be first param to consistency with other apis
af/merge-core
Scott Williams 9 years ago
parent
commit
41b1833e8f
  1. 2
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
  2. 2
      src/ImageSharp/Formats/Gif/GifDecoderCore.cs
  3. 2
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  4. 2
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  5. 6
      src/ImageSharp/Image/ImageBase{TPixel}.cs
  6. 2
      src/ImageSharp/Image/ImageFrame{TPixel}.cs
  7. 22
      src/ImageSharp/Image/Image{TPixel}.cs
  8. 2
      tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs
  9. 6
      tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs
  10. 5
      tests/ImageSharp.Tests/Image/ImageSaveTests.cs

2
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

@ -127,7 +127,7 @@ namespace ImageSharp.Formats
+ $"bigger then the max allowed size '{Image<TPixel>.MaxWidth}x{Image<TPixel>.MaxHeight}'");
}
Image<TPixel> image = new Image<TPixel>(this.infoHeader.Width, this.infoHeader.Height, this.configuration);
Image<TPixel> image = new Image<TPixel>(this.configuration, this.infoHeader.Width, this.infoHeader.Height);
using (PixelAccessor<TPixel> pixels = image.Lock())
{
switch (this.infoHeader.Compression)

2
src/ImageSharp/Formats/Gif/GifDecoderCore.cs

@ -366,7 +366,7 @@ namespace ImageSharp.Formats
this.metaData.Quality = colorTableLength / 3;
// This initializes the image to become fully transparent because the alpha channel is zero.
this.image = new Image<TPixel>(imageWidth, imageHeight, this.metaData, this.configuration);
this.image = new Image<TPixel>(this.configuration, imageWidth, imageHeight, this.metaData);
this.SetFrameMetaData(this.metaData);

2
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -482,7 +482,7 @@ namespace ImageSharp.Formats
private Image<TPixel> ConvertJpegPixelsToImagePixels<TPixel>(ImageMetaData metadata)
where TPixel : struct, IPixel<TPixel>
{
Image<TPixel> image = new Image<TPixel>(this.ImageWidth, this.ImageHeight, metadata, this.configuration);
Image<TPixel> image = new Image<TPixel>(this.configuration, this.ImageWidth, this.ImageHeight, metadata);
if (this.grayImage.IsInitialized)
{

2
src/ImageSharp/Formats/Png/PngDecoderCore.cs

@ -335,7 +335,7 @@ namespace ImageSharp.Formats
throw new ArgumentOutOfRangeException($"The input png '{this.header.Width}x{this.header.Height}' is bigger than the max allowed size '{Image<TPixel>.MaxWidth}x{Image<TPixel>.MaxHeight}'");
}
image = new Image<TPixel>(this.header.Width, this.header.Height, metadata, this.configuration);
image = new Image<TPixel>(this.configuration, this.header.Width, this.header.Height, metadata);
pixels = image.Lock();
this.bytesPerPixel = this.CalculateBytesPerPixel();
this.bytesPerScanline = this.CalculateScanlineLength(this.header.Width) + 1;

6
src/ImageSharp/Image/ImageBase{TPixel}.cs

@ -59,15 +59,15 @@ namespace ImageSharp
/// <summary>
/// Initializes a new instance of the <see cref="ImageBase{TPixel}"/> class.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown if either <paramref name="width"/> or <paramref name="height"/> are less than or equal to 0.
/// </exception>
protected ImageBase(int width, int height, Configuration configuration)
protected ImageBase(Configuration configuration, int width, int height)
: this(configuration)
{
Guard.MustBeGreaterThan(width, 0, nameof(width));

2
src/ImageSharp/Image/ImageFrame{TPixel}.cs

@ -26,7 +26,7 @@ namespace ImageSharp
/// The configuration providing initialization code which allows extending the library.
/// </param>
public ImageFrame(int width, int height, Configuration configuration = null)
: base(width, height, configuration)
: base(configuration, width, height)
{
}

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

@ -29,13 +29,13 @@ namespace ImageSharp
/// Initializes a new instance of the <see cref="Image{TPixel}"/> class
/// with the height and the width of the image.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
public Image(int width, int height, Configuration configuration)
: this(width, height, new ImageMetaData(), configuration)
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
public Image(Configuration configuration, int width, int height)
: this(configuration, width, height, new ImageMetaData())
{
}
@ -46,7 +46,7 @@ namespace ImageSharp
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
public Image(int width, int height)
: this(width, height, null)
: this(null, width, height)
{
}
@ -85,14 +85,14 @@ namespace ImageSharp
/// Initializes a new instance of the <see cref="Image{TPixel}"/> class
/// with the height and the width of the image.
/// </summary>
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="metadata">The images metadata.</param>
/// <param name="configuration">
/// The configuration providing initialization code which allows extending the library.
/// </param>
internal Image(int width, int height, ImageMetaData metadata, Configuration configuration)
: base(width, height, configuration)
/// <param name="width">The width of the image in pixels.</param>
/// <param name="height">The height of the image in pixels.</param>
/// <param name="metadata">The images metadata.</param>
internal Image(Configuration configuration, int width, int height, ImageMetaData metadata)
: base(configuration, width, height)
{
if (!this.Configuration.ImageFormats.Any())
{
@ -359,7 +359,7 @@ namespace ImageSharp
{
scaleFunc = PackedPixelConverterHelper.ComputeScaleFunction<TPixel, TPixel2>(scaleFunc);
Image<TPixel2> target = new Image<TPixel2>(this.Width, this.Height, this.Configuration);
Image<TPixel2> target = new Image<TPixel2>(this.Configuration, this.Width, this.Height);
target.CopyProperties(this);
using (PixelAccessor<TPixel> pixels = this.Lock())

2
tests/ImageSharp.Tests/Drawing/Paths/ProcessorWatchingImage.cs

@ -17,7 +17,7 @@ namespace ImageSharp.Tests.Drawing.Paths
public List<ProcessorDetails> ProcessorApplications { get; } = new List<ProcessorDetails>();
public ProcessorWatchingImage(int width, int height)
: base(width, height, Configuration.CreateDefaultInstance())
: base(Configuration.CreateDefaultInstance(), width, height)
{
}

6
tests/ImageSharp.Tests/Drawing/SolidPolygonTests.cs

@ -217,7 +217,7 @@ namespace ImageSharp.Tests.Drawing
Configuration config = Configuration.CreateDefaultInstance();
config.ParallelOptions.MaxDegreeOfParallelism = 1;
using (Image<Rgba32> image = new Image<Rgba32>(100, 100, config))
using (Image<Rgba32> image = new Image<Rgba32>(config, 100, 100))
{
using (FileStream output = File.OpenWrite($"{path}/Septagon.png"))
{
@ -236,7 +236,7 @@ namespace ImageSharp.Tests.Drawing
Configuration config = Configuration.CreateDefaultInstance();
config.ParallelOptions.MaxDegreeOfParallelism = 1;
using (Image<Rgba32> image = new Image<Rgba32>(100, 100, config))
using (Image<Rgba32> image = new Image<Rgba32>(config, 100, 100))
{
using (FileStream output = File.OpenWrite($"{path}/ellipse.png"))
{
@ -256,7 +256,7 @@ namespace ImageSharp.Tests.Drawing
Configuration config = Configuration.CreateDefaultInstance();
config.ParallelOptions.MaxDegreeOfParallelism = 1;
using (Image<Rgba32> image = new Image<Rgba32>(200, 200, config))
using (Image<Rgba32> image = new Image<Rgba32>(config, 200, 200))
{
using (FileStream output = File.OpenWrite($"{path}/clipped-corner.png"))
{

5
tests/ImageSharp.Tests/Image/ImageSaveTests.cs

@ -49,9 +49,10 @@ namespace ImageSharp.Tests
this.fileSystem = new Mock<IFileSystem>();
this.encoderOptions = new Mock<IEncoderOptions>().Object;
this.Image = new Image<Rgba32>(1, 1, new Configuration(this.format.Object) {
this.Image = new Image<Rgba32>(new Configuration(this.format.Object)
{
FileSystem = this.fileSystem.Object
});
}, 1, 1);
}
[Fact]

Loading…
Cancel
Save