PngCodec
Ecng.Drawing
Managed PNG decoder/encoder (all standard color types, 1/2/4/8/16-bit samples, Adam7).
方法
Compress
public static byte[] Compress(RasterImage image)
result = PngCodec.Compress(image)
Packs the pixels the way an IDAT chunk of an RGBA8 picture holds them: scanlines in a zlib stream, filtered if that makes the stream shorter.
Crc
public static uint Crc(ReadOnlySpan<byte> content)
result = PngCodec.Crc(content)
The checksum of a chunk: of its tag and its content together.
Encode
public static byte[] Encode(RasterImage image, byte[] colorChunks)
result = PngCodec.Encode(image, colorChunks)
Writes a picture as an RGBA8 PNG.
- image
- The picture.
- colorChunks
- The chunks that say what colors the samples are, whole and ready to be written: what Byte}) or Byte[]) gave. Empty for none.
ProfileChunk
public static byte[] ProfileChunk(byte[] profile)
result = PngCodec.ProfileChunk(profile)
Makes the iCCP chunk that holds an ICC profile.
- profile
- The profile; empty for none.
返回值: The chunk, whole; empty if there is no profile.
ReadColorChunks
public static byte[] ReadColorChunks(ReadOnlySpan<byte> data)
result = PngCodec.ReadColorChunks(data)
Reads the chunks of a PNG that say what colors its samples are - cHRM, gAMA, iCCP, sRGB - so that a picture made of it can say the same.
返回值: The chunks, whole, one after another. A profile is among them only if it can go into a re-encoded picture (see Byte})), and sRGB only if there is no profile: a file holds one or the other.