private void WriteImageGamma() { using (var chunk = new PngChunkStream(output, PngChunkIdentifier.ImageGamma)) { chunk.WriteBigEndian(45455); } }
private void WriteTextualData(string key, string value) { using (var chunk = new PngChunkStream(output, PngChunkIdentifier.TextualData)) { chunk.Write(key); chunk.WriteByte(0); chunk.Write(value); } }
private void WriteTransparency() { if (palette.Count == 0 || !palette.HasAlphaChannel) { return; } using (var chunk = new PngChunkStream(output, PngChunkIdentifier.Transparency)) { for (var i = 0; i < palette.Count; i++) { chunk.WriteByte((byte)palette[i].A); } } }
private void WriteImageHeader() { using (var chunk = new PngChunkStream(output, PngChunkIdentifier.ImageHeader)) { var colorType = palette.Count > 0 ? PngColorType.IndexedColour : PngColorType.TruecolourWithAlpha; chunk.WriteBigEndian(Width); chunk.WriteBigEndian(Height); chunk.WriteByte(8); // Bit depth chunk.WriteByte(colorType); chunk.WriteByte(0); // Compression chunk.WriteByte(0); // Filter chunk.WriteByte(0); // Interlace } }
private void WriteImageData() { using (var chunk = new PngChunkStream(output, PngChunkIdentifier.ImageData)) { using (var deflate = new ZlibStream(chunk)) { if (palette.Count > 0) { WriteIndexed(deflate); } else { WriteTrueColorWithAlpha(deflate); } } } }
private void WritePalette() { if (palette.Count == 0) { return; } using (var chunk = new PngChunkStream(output, PngChunkIdentifier.Palette)) { for (var i = 0; i < palette.Count; i++) { chunk.WriteByte((byte)palette[i].R); chunk.WriteByte((byte)palette[i].G); chunk.WriteByte((byte)palette[i].B); } } }