Browse Source

Merge pull request #325 from shutdown256/shutdown256-patch-1

Shutdown256 patch 1

Former-commit-id: cfa0039cb671ca2e6b76d03fb1fb22e6b41057af
Former-commit-id: c3d855f7f995ffac2e253674e623243ff9f496cf
Former-commit-id: da599171b6f706761629dc1ded370b78b847d24e
af/merge-core
James Jackson-South 10 years ago
parent
commit
d600a07566
  1. 5
      src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs
  2. 7
      src/ImageProcessorCore/Formats/Png/PaletteIndexReader.cs

5
src/ImageProcessorCore/Common/Extensions/ByteExtensions.cs

@ -32,7 +32,8 @@ namespace ImageProcessorCore
{
result = new byte[bytes.Length * 8 / bits];
int factor = (int)Math.Pow(2, bits) - 1;
// BUGFIX I dont think it should be there, but I am not sure if it breaks something else
//int factor = (int)Math.Pow(2, bits) - 1;
int mask = 0xFF >> (8 - bits);
int resultOffset = 0;
@ -40,7 +41,7 @@ namespace ImageProcessorCore
{
for (int shift = 0; shift < 8; shift += bits)
{
int colorIndex = ((b >> (8 - bits - shift)) & mask) * (255 / factor);
int colorIndex = ((b >> (8 - bits - shift)) & mask); // * (255 / factor);
result[resultOffset] = (byte)colorIndex;

7
src/ImageProcessorCore/Formats/Png/PaletteIndexReader.cs

@ -56,9 +56,10 @@ namespace ImageProcessorCore.Formats
offset = ((this.row * header.Width) + i) * 4;
int pixelOffset = index * 3;
float r = newScanline[pixelOffset] / 255f;
float g = newScanline[pixelOffset + 1] / 255f;
float b = newScanline[pixelOffset + 2] / 255f;
// BUGFIX changed newScanline[] to this.palette[] , 99% sure it was a typo and not intent
float r = this.palette[pixelOffset] / 255f;
float g = this.palette[pixelOffset + 1] / 255f;
float b = this.palette[pixelOffset + 2] / 255f;
float a = this.paletteAlpha.Length > index
? this.paletteAlpha[index] / 255f
: 1;

Loading…
Cancel
Save