/// <exception cref="PngProcessingException"/> public PngHeader([NotNull] byte[] bytes) { if (bytes.Length != 13) { throw new PngProcessingException("PNG header chunk must have exactly 13 data bytes"); } var reader = new SequentialByteArrayReader(bytes); ImageWidth = reader.GetInt32(); ImageHeight = reader.GetInt32(); BitsPerSample = reader.GetByte(); var colorTypeNumber = reader.GetByte(); var colorType = PngColorType.FromNumericValue(colorTypeNumber); if (colorType == null) { throw new PngProcessingException("Unexpected PNG color type: " + colorTypeNumber); } ColorType = colorType; CompressionType = reader.GetByte(); FilterMethod = reader.GetByte(); InterlaceMethod = reader.GetByte(); }
public string GetColorTypeDescription() { if (!Directory.TryGetInt32(PngDirectory.TagColorType, out int value)) { return(null); } return(PngColorType.FromNumericValue(value).Description); }
/// <exception cref="PngProcessingException"/> public PngHeader(byte[] bytes) { if (bytes.Length != 13) { throw new PngProcessingException("PNG header chunk must have exactly 13 data bytes"); } var reader = new SequentialByteArrayReader(bytes); ImageWidth = reader.GetInt32(); ImageHeight = reader.GetInt32(); BitsPerSample = reader.GetByte(); ColorType = PngColorType.FromNumericValue(reader.GetByte()); CompressionType = reader.GetByte(); FilterMethod = reader.GetByte(); InterlaceMethod = reader.GetByte(); }