Browse Source

Merge pull request #167 from JimBobSquarePants/indexed-png-fix

Fix for off by one for indexed pngs
af/merge-core
James Jackson-South 9 years ago
committed by GitHub
parent
commit
2cda2814be
  1. 6
      src/ImageSharp/Formats/Png/PngDecoderCore.cs

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

@ -579,7 +579,7 @@ namespace ImageSharp.Formats
// channel and we should try to read it. // channel and we should try to read it.
for (int x = 0; x < this.header.Width; x++) for (int x = 0; x < this.header.Width; x++)
{ {
int index = newScanline[x]; int index = newScanline[x + 1];
int pixelOffset = index * 3; int pixelOffset = index * 3;
byte a = this.paletteAlpha.Length > index ? this.paletteAlpha[index] : (byte)255; byte a = this.paletteAlpha.Length > index ? this.paletteAlpha[index] : (byte)255;
@ -603,7 +603,7 @@ namespace ImageSharp.Formats
{ {
for (int x = 0; x < this.header.Width; x++) for (int x = 0; x < this.header.Width; x++)
{ {
int index = newScanline[x]; int index = newScanline[x + 1];
int pixelOffset = index * 3; int pixelOffset = index * 3;
byte r = this.palette[pixelOffset]; byte r = this.palette[pixelOffset];
@ -982,4 +982,4 @@ namespace ImageSharp.Formats
} }
} }
} }
} }

Loading…
Cancel
Save