Browse Source

Fix indexed png transparecy

Former-commit-id: 22b1bb758cdbd1a858c7e3cdcc1896c67302ad51
Former-commit-id: 9439de1c305648648f7348a9b7852b137c83720a
Former-commit-id: 7a1d86a944909bd5e68ea96070ecf16641d3b1db
af/merge-core
James Jackson-South 10 years ago
parent
commit
c92ab3b807
  1. 12
      src/ImageProcessorCore/Formats/Png/PngEncoderCore.cs

12
src/ImageProcessorCore/Formats/Png/PngEncoderCore.cs

@ -89,7 +89,11 @@ namespace ImageProcessorCore.Formats
0, 0,
8); 8);
this.Quality = image.Quality.Clamp(1, int.MaxValue); if (image.Quality > 0)
{
this.Quality = image.Quality.Clamp(1, int.MaxValue);
}
this.bitDepth = this.Quality <= 256 this.bitDepth = this.Quality <= 256
? (byte)(this.GetBitsNeededForColorDepth(this.Quality).Clamp(1, 8)) ? (byte)(this.GetBitsNeededForColorDepth(this.Quality).Clamp(1, 8))
@ -234,11 +238,7 @@ namespace ImageProcessorCore.Formats
// Write the transparency data // Write the transparency data
if (this.quantized.TransparentIndex > -1) if (this.quantized.TransparentIndex > -1)
{ {
byte[] buffer = BitConverter.GetBytes(this.quantized.TransparentIndex); this.WriteChunk(stream, PngChunkTypes.PaletteAlpha, new[] { (byte)this.quantized.TransparentIndex });
Array.Reverse(buffer);
this.WriteChunk(stream, PngChunkTypes.PaletteAlpha, buffer);
} }
} }

Loading…
Cancel
Save