Browse Source

fix #277

pull/283/head
Nikita Balabaev 9 years ago
parent
commit
ba6e00499c
  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. BIN
      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; using System.Collections.Generic;
/// <summary> /// <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> /// </summary>
internal sealed class BmpFormat : IImageFormat internal sealed class BmpFormat : IImageFormat
{ {

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

@ -8,7 +8,7 @@ namespace ImageSharp.Formats
using System.Collections.Generic; using System.Collections.Generic;
/// <summary> /// <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> /// </summary>
internal sealed class GifFormat : IImageFormat 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)) using (var compressed = new Buffer<byte>(length))
{ {
// TODO: Should we use pack from vector here instead? // TODO: Should we use pack from vector here instead?
this.From16BitTo8Bit(new Span<byte>(defilteredScanline), compressed, length); this.From16BitTo8Bit(new Span<byte>(defilteredScanline, 1), compressed, length);
for (int x = pixelOffset, o = 1; for (int x = pixelOffset, o = 0;
x < this.header.Width; x < this.header.Width;
x += increment, o += this.bytesPerPixel) x += increment, o += 3)
{ {
rgba.R = compressed[o]; rgba.R = compressed[o];
rgba.G = compressed[o + this.bytesPerSample]; rgba.G = compressed[o + 1];
rgba.B = compressed[o + (2 * this.bytesPerSample)]; rgba.B = compressed[o + 2];
color.PackFromRgba32(rgba); color.PackFromRgba32(rgba);
rowSpan[x] = color; rowSpan[x] = color;
@ -862,13 +862,13 @@ namespace ImageSharp.Formats
using (var compressed = new Buffer<byte>(length)) using (var compressed = new Buffer<byte>(length))
{ {
// TODO: Should we use pack from vector here instead? // TODO: Should we use pack from vector here instead?
this.From16BitTo8Bit(new Span<byte>(defilteredScanline), compressed, length); this.From16BitTo8Bit(new Span<byte>(defilteredScanline, 1), compressed, length);
for (int x = pixelOffset, o = 1; x < this.header.Width; x += increment, o += this.bytesPerPixel) for (int x = pixelOffset, o = 0; x < this.header.Width; x += increment, o += 4)
{ {
rgba.R = compressed[o]; rgba.R = compressed[o];
rgba.G = compressed[o + this.bytesPerSample]; rgba.G = compressed[o + 1];
rgba.B = compressed[o + (2 * this.bytesPerSample)]; rgba.B = compressed[o + 2];
rgba.A = compressed[o + (3 * this.bytesPerSample)]; rgba.A = compressed[o + 3];
color.PackFromRgba32(rgba); color.PackFromRgba32(rgba);
rowSpan[x] = color; rowSpan[x] = color;

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

@ -8,7 +8,7 @@ namespace ImageSharp.Formats
using System.Collections.Generic; using System.Collections.Generic;
/// <summary> /// <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> /// </summary>
internal sealed class PngFormat : IImageFormat 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 = public static readonly string[] TestFiles =
{ {
TestImages.Png.Splash, TestImages.Png.Indexed, TestImages.Png.Interlaced, TestImages.Png.FilterVar, 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] [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 SplashInterlaced = "Png/splash-interlaced.png";
public const string Interlaced = "Png/interlaced.png"; public const string Interlaced = "Png/interlaced.png";
public const string Rgb48Bpp = "Png/rgb-48bpp.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 // Filtered test images from http://www.schaik.com/pngsuite/pngsuite_fil_png.html
public const string Filter0 = "Png/filter0.png"; public const string Filter0 = "Png/filter0.png";

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Loading…
Cancel
Save