Browse Source

All tests now pass

af/merge-core
James Jackson-South 8 years ago
parent
commit
e808514648
  1. 38
      src/ImageSharp/Formats/Png/PngEncoderCore.cs
  2. 13
      tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
  3. 4
      tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs
  4. 2
      tests/Images/External

38
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -5,8 +5,6 @@ using System;
using System.Buffers.Binary; using System.Buffers.Binary;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced; using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Formats.Png.Filters; using SixLabors.ImageSharp.Formats.Png.Filters;
using SixLabors.ImageSharp.Formats.Png.Zlib; using SixLabors.ImageSharp.Formats.Png.Zlib;
@ -394,7 +392,6 @@ namespace SixLabors.ImageSharp.Formats.Png
switch (this.pngColorType) switch (this.pngColorType)
{ {
case PngColorType.Palette: case PngColorType.Palette:
// TODO: Use Span copy!
Buffer.BlockCopy(this.palettePixelData, row * this.rawScanline.Length(), this.rawScanline.Array, 0, this.rawScanline.Length()); Buffer.BlockCopy(this.palettePixelData, row * this.rawScanline.Length(), this.rawScanline.Array, 0, this.rawScanline.Length());
break; break;
case PngColorType.Grayscale: case PngColorType.Grayscale:
@ -646,12 +643,37 @@ namespace SixLabors.ImageSharp.Formats.Png
this.rawScanline = this.memoryAllocator.AllocateCleanManagedByteBuffer(this.bytesPerScanline); this.rawScanline = this.memoryAllocator.AllocateCleanManagedByteBuffer(this.bytesPerScanline);
this.result = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); this.result = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
if (this.pngColorType != PngColorType.Palette) switch (this.pngFilterMethod)
{ {
this.sub = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); case PngFilterMethod.None:
this.up = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); break;
this.average = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
this.paeth = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength); case PngFilterMethod.Sub:
this.sub = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
break;
case PngFilterMethod.Up:
this.up = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
break;
case PngFilterMethod.Average:
this.average = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
break;
case PngFilterMethod.Paeth:
this.paeth = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
break;
case PngFilterMethod.Adaptive:
this.sub = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
this.up = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
this.average = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
this.paeth = this.memoryAllocator.AllocateCleanManagedByteBuffer(resultLength);
break;
} }
byte[] buffer; byte[] buffer;

13
tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs

@ -84,12 +84,13 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
} }
var textOptions = new TextGraphicsOptions var textOptions = new TextGraphicsOptions
{ {
Antialias = true, Antialias = true,
ApplyKerning = true, ApplyKerning = true,
VerticalAlignment = VerticalAlignment.Top, VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left, HorizontalAlignment = HorizontalAlignment.Left,
}; };
TPixel color = NamedColors<TPixel>.Black; TPixel color = NamedColors<TPixel>.Black;
provider.VerifyOperation( provider.VerifyOperation(

4
tests/ImageSharp.Tests/TestUtilities/Tests/TestEnvironmentTests.cs

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.Tests
} }
[Theory] [Theory]
[InlineData("lol/foo.png", typeof(SystemDrawingReferenceEncoder))] [InlineData("lol/foo.png", typeof(PngEncoder))]
[InlineData("lol/Rofl.bmp", typeof(SystemDrawingReferenceEncoder))] [InlineData("lol/Rofl.bmp", typeof(SystemDrawingReferenceEncoder))]
[InlineData("lol/Baz.JPG", typeof(JpegEncoder))] [InlineData("lol/Baz.JPG", typeof(JpegEncoder))]
[InlineData("lol/Baz.gif", typeof(GifEncoder))] [InlineData("lol/Baz.gif", typeof(GifEncoder))]
@ -73,7 +73,7 @@ namespace SixLabors.ImageSharp.Tests
} }
[Theory] [Theory]
[InlineData("lol/foo.png", typeof(SystemDrawingReferenceDecoder))] [InlineData("lol/foo.png", typeof(PngDecoder))]
[InlineData("lol/Rofl.bmp", typeof(SystemDrawingReferenceDecoder))] [InlineData("lol/Rofl.bmp", typeof(SystemDrawingReferenceDecoder))]
[InlineData("lol/Baz.JPG", typeof(JpegDecoder))] [InlineData("lol/Baz.JPG", typeof(JpegDecoder))]
[InlineData("lol/Baz.gif", typeof(GifDecoder))] [InlineData("lol/Baz.gif", typeof(GifDecoder))]

2
tests/Images/External

@ -1 +1 @@
Subproject commit 0e6407be7081341526f815a4d70e7912db276a98 Subproject commit 147306294437dc03f6e640f5db2dcd496a43ced7
Loading…
Cancel
Save