Browse Source

fix #277

af/merge-core
Nikita Balabaev 9 years ago
parent
commit
74b0d0aff2
  1. 2
      src/ImageSharp/Formats/Bmp/BmpFormat.cs
  2. 2
      src/ImageSharp/Formats/Gif/GifFormat.cs
  3. 20
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  4. 2
      src/ImageSharp/Formats/Png/PngFormat.cs
  5. 2
      tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs
  6. 1
      tests/ImageSharp.Tests/TestImages.cs
  7. 3
      tests/ImageSharp.Tests/TestImages/Formats/Png/rgb-48bpp-interlaced.png

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

@ -8,7 +8,7 @@ namespace ImageSharp.Formats
using System.Collections.Generic;
/// <summary>
/// Registers the image encoders, decoders and mime type detectors for the jpeg format.
/// Registers the image encoders, decoders and mime type detectors for the bmp format.
/// </summary>
internal sealed class BmpFormat : IImageFormat
{

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

@ -8,7 +8,7 @@ namespace ImageSharp.Formats
using System.Collections.Generic;
/// <summary>
/// Registers the image encoders, decoders and mime type detectors for the jpeg format.
/// Registers the image encoders, decoders and mime type detectors for the gif format.
/// </summary>
internal sealed class GifFormat : IImageFormat
{

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

@ -825,14 +825,14 @@ namespace ImageSharp.Formats
using (var compressed = new Buffer<byte>(length))
{
// TODO: Should we use pack from vector here instead?
this.From16BitTo8Bit(new Span<byte>(defilteredScanline), compressed, length);
for (int x = pixelOffset, o = 1;
this.From16BitTo8Bit(new Span<byte>(defilteredScanline, 1), compressed, length);
for (int x = pixelOffset, o = 0;
x < this.header.Width;
x += increment, o += this.bytesPerPixel)
x += increment, o += 3)
{
rgba.R = compressed[o];
rgba.G = compressed[o + this.bytesPerSample];
rgba.B = compressed[o + (2 * this.bytesPerSample)];
rgba.G = compressed[o + 1];
rgba.B = compressed[o + 2];
color.PackFromRgba32(rgba);
rowSpan[x] = color;
@ -862,13 +862,13 @@ namespace ImageSharp.Formats
using (var compressed = new Buffer<byte>(length))
{
// TODO: Should we use pack from vector here instead?
this.From16BitTo8Bit(new Span<byte>(defilteredScanline), compressed, length);
for (int x = pixelOffset, o = 1; x < this.header.Width; x += increment, o += this.bytesPerPixel)
this.From16BitTo8Bit(new Span<byte>(defilteredScanline, 1), compressed, length);
for (int x = pixelOffset, o = 0; x < this.header.Width; x += increment, o += 4)
{
rgba.R = compressed[o];
rgba.G = compressed[o + this.bytesPerSample];
rgba.B = compressed[o + (2 * this.bytesPerSample)];
rgba.A = compressed[o + (3 * this.bytesPerSample)];
rgba.G = compressed[o + 1];
rgba.B = compressed[o + 2];
rgba.A = compressed[o + 3];
color.PackFromRgba32(rgba);
rowSpan[x] = color;

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

@ -8,7 +8,7 @@ namespace ImageSharp.Formats
using System.Collections.Generic;
/// <summary>
/// Registers the image encoders, decoders and mime type detectors for the jpeg format.
/// Registers the image encoders, decoders and mime type detectors for the png format.
/// </summary>
internal sealed class PngFormat : IImageFormat
{

2
tests/ImageSharp.Tests/Formats/Png/PngDecoderTests.cs

@ -18,7 +18,7 @@ namespace ImageSharp.Tests
public static readonly string[] TestFiles =
{
TestImages.Png.Splash, TestImages.Png.Indexed, TestImages.Png.Interlaced, TestImages.Png.FilterVar,
TestImages.Png.Bad.ChunkLength1, TestImages.Png.Bad.ChunkLength2, TestImages.Png.Rgb48Bpp
TestImages.Png.Bad.ChunkLength1, TestImages.Png.Bad.ChunkLength2, TestImages.Png.Rgb48Bpp, TestImages.Png.Rgb48BppInterlaced
};
[Theory]

1
tests/ImageSharp.Tests/TestImages.cs

@ -26,6 +26,7 @@ namespace ImageSharp.Tests
public const string SplashInterlaced = "Png/splash-interlaced.png";
public const string Interlaced = "Png/interlaced.png";
public const string Rgb48Bpp = "Png/rgb-48bpp.png";
public const string Rgb48BppInterlaced = "Png/rgb-48bpp-interlaced.png";
// Filtered test images from http://www.schaik.com/pngsuite/pngsuite_fil_png.html
public const string Filter0 = "Png/filter0.png";

3
tests/ImageSharp.Tests/TestImages/Formats/Png/rgb-48bpp-interlaced.png

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:79d1705ef6438d90dc145068141d4e32c1cf1cd5cf17c7b90b7ecb12967016bd
size 69952
Loading…
Cancel
Save