//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp.Formats
{
using System.Collections.Generic;
///
/// Encapsulates the means to encode and decode png images.
///
public class PngFormat : IImageFormat
{
///
public string MimeType => "image/png";
///
public string Extension => "png";
///
public IEnumerable SupportedExtensions => new string[] { "png" };
///
public IImageDecoder Decoder => new PngDecoder();
///
public IImageEncoder Encoder => new PngEncoder();
///
public int HeaderSize => 8;
///
public bool IsSupportedFileFormat(byte[] header)
{
return header.Length >= this.HeaderSize &&
header[0] == 0x89 &&
header[1] == 0x50 && // P
header[2] == 0x4E && // N
header[3] == 0x47 && // G
header[4] == 0x0D && // CR
header[5] == 0x0A && // LF
header[6] == 0x1A && // EOF
header[7] == 0x0A; // LF
}
}
}