Browse Source

Merge branch 'master' into beta-1

af/merge-core
James Jackson-South 9 years ago
parent
commit
8a8f3a9138
  1. 2
      .github/PULL_REQUEST_TEMPLATE.md
  2. 29
      src/ImageSharp/Formats/Png/Filters/PaethFilter.cs
  3. 5
      src/ImageSharp/Formats/Png/PngDecoderCore.cs

2
.github/PULL_REQUEST_TEMPLATE.md

@ -2,7 +2,7 @@
- [ ] I have written a descriptive pull-request title - [ ] I have written a descriptive pull-request title
- [ ] I have verified that there are no overlapping [pull-requests](https://github.com/JimBobSquarePants/ImageSharp/pulls) open - [ ] I have verified that there are no overlapping [pull-requests](https://github.com/JimBobSquarePants/ImageSharp/pulls) open
- [ ] I have verified that I am following matches the existing coding patterns and practise as demonstrated in the repository. These follow strict Stylecop rules :cop:. - [ ] I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:.
- [ ] I have provided test coverage for my change (where applicable) - [ ] I have provided test coverage for my change (where applicable)
### Description ### Description

29
src/ImageSharp/Formats/Png/Filters/PaethFilter.cs

@ -29,22 +29,21 @@ namespace SixLabors.ImageSharp.Formats.Png.Filters
ref byte prevBaseRef = ref previousScanline.DangerousGetPinnableReference(); ref byte prevBaseRef = ref previousScanline.DangerousGetPinnableReference();
// Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp)) // Paeth(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp))
for (int x = 1; x < scanline.Length; x++) int offset = bytesPerPixel + 1;
for (int x = 1; x < offset; x++)
{ {
if (x - bytesPerPixel < 1) ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
{ byte above = Unsafe.Add(ref prevBaseRef, x);
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); scan = (byte)(scan + above);
byte above = Unsafe.Add(ref prevBaseRef, x); }
scan = (byte)((scan + PaethPredicator(0, above, 0)) % 256);
} for (int x = offset; x < scanline.Length; x++)
else {
{ ref byte scan = ref Unsafe.Add(ref scanBaseRef, x);
ref byte scan = ref Unsafe.Add(ref scanBaseRef, x); byte left = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel);
byte left = Unsafe.Add(ref scanBaseRef, x - bytesPerPixel); byte above = Unsafe.Add(ref prevBaseRef, x);
byte above = Unsafe.Add(ref prevBaseRef, x); byte upperLeft = Unsafe.Add(ref prevBaseRef, x - bytesPerPixel);
byte upperLeft = Unsafe.Add(ref prevBaseRef, x - bytesPerPixel); scan = (byte)(scan + PaethPredicator(left, above, upperLeft));
scan = (byte)((scan + PaethPredicator(left, above, upperLeft)) % 256);
}
} }
} }

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

@ -515,7 +515,7 @@ namespace SixLabors.ImageSharp.Formats.Png
this.currentRowBytesRead = 0; this.currentRowBytesRead = 0;
Span<byte> scanSpan = this.scanline.Slice(0, bytesPerInterlaceScanline); Span<byte> scanSpan = this.scanline.Slice(0, bytesPerInterlaceScanline);
Span<byte> prevSpan = this.previousScanline.Span.Slice(0, bytesPerInterlaceScanline); Span<byte> prevSpan = this.previousScanline.Slice(0, bytesPerInterlaceScanline);
var filterType = (FilterType)scanSpan[0]; var filterType = (FilterType)scanSpan[0];
switch (filterType) switch (filterType)
@ -556,12 +556,15 @@ namespace SixLabors.ImageSharp.Formats.Png
} }
this.pass++; this.pass++;
this.previousScanline.Clear();
if (this.pass < 7) if (this.pass < 7)
{ {
this.currentRow = Adam7FirstRow[this.pass]; this.currentRow = Adam7FirstRow[this.pass];
} }
else else
{ {
this.pass = 0;
break; break;
} }
} }

Loading…
Cancel
Save