PngChunk Class
An immutable ancillary chunk of a PNG file that the library does not interpret (a private chunk, or a public chunk such as gAMA, bKGD or tIME that it reads into no other metadata): its type, its data and its position.
public sealed class PngChunk : IEquatable<PngChunk>Remarks
The case of the letters of the type carries its properties (PNG specification, section 5.4): an ancillary chunk has a lowercase first letter, a private chunk a lowercase second letter, and a chunk that can be copied whatever the changes to the image has a lowercase fourth letter (PngChunk.IsSafeToCopy). The third letter is uppercase.
PngEncoder writes the chunks at their position. Because it encodes the image data again, it only writes the chunks that are safe to copy unless PngEncoder.WriteUnsafeToCopyChunks says that the others still describe the image (PNG specification, section 14.2). The other encoders ignore the chunks.
- Implements
Constructors
| Name | Description |
|---|---|
| PngChunk(string, MetadataBlob, PngChunkPosition) | Initializes a new instance of the PngChunk class. |
PngChunk(string, MetadataBlob, PngChunkPosition)
PngChunk.csInitializes a new instance of the PngChunk class.
public PngChunk(string type, MetadataBlob data, PngChunkPosition position = PngChunkPosition.BeforeImageData)Parameters
typestring- The type: four ASCII letters, the first lowercase (ancillary) and the third uppercase.
dataMetadataBlob- The data of the chunk, without its length, type and CRC.
positionPngChunkPosition- Where the chunk is written relative to the critical chunks.
Exceptions
ArgumentNullExceptiontypeordataisnull.ArgumentExceptiontypeis not four ASCII letters, is a critical chunk (uppercase first letter), has a lowercase third letter (reserved), or is a chunk the library reads or writes itself (tRNS,pHYs,iCCP,cICP,mDCV,cLLI,eXIf,tEXt,zTXt,iTXt,acTL,fcTL,fdAT).ArgumentOutOfRangeExceptionpositionis not a definedPngChunkPosition.
Properties
| Name | Description |
|---|---|
| Data | Gets the data of the chunk. |
| IsPrivate | Gets a value indicating whether the chunk is private (a lowercase second letter), rather than defined by the PNG specification or registered. |
| IsSafeToCopy | Gets a value indicating whether the chunk can be copied to a file whose image data changed (a lowercase fourth letter): otherwise it depends on the image data, and is only valid for the image it was written with. |
| Position | Gets where the chunk lies relative to the critical chunks. |
| Type | Gets the type of the chunk: four ASCII letters. |
Data
PngChunk.csIsPrivate
PngChunk.csIsSafeToCopy
PngChunk.csPosition
PngChunk.csGets where the chunk lies relative to the critical chunks.
public PngChunkPosition Position { get; }Property value
Type
PngChunk.csMethods
| Name | Description |
|---|---|
| Equals(PngChunk?) | Indicates whether the current object is equal to another object of the same type. |
| Equals(object?) | Determines whether the specified object is equal to the current object. |
| GetHashCode() | Serves as the default hash function. |
| ToString() | Returns a string that represents the current object. |