PngCs  1.1.4
A C# library for read/write PNG images
Public Member Functions | List of all members
Hjg.Pngcs.Chunks.PngMetadata Class Reference

Image Metadata, wrapper over a ChunksList More...

Public Member Functions

void QueueChunk (PngChunk chunk, bool lazyOverwrite)
 Queues the chunk at the writer
 
void QueueChunk (PngChunk chunk)
 Queues the chunk at the writer
 
double[] GetDpi ()
 Returns physical resolution, in DPI, in both coordinates
 
void SetDpi (double dpix, double dpiy)
 Sets physical resolution, in DPI
 
void SetDpi (double dpi)
 Sets physical resolution, in DPI, both value in x and y dimensions
 
PngChunkTIME SetTimeNow (int nsecs)
 Creates a TIME chunk, nsecs in the past from now.
 
PngChunkTIME SetTimeNow ()
 Creates a TIME chunk with current time.
 
PngChunkTIME SetTimeYMDHMS (int year, int mon, int day, int hour, int min, int sec)
 Creates a TIME chunk with given date and time
 
PngChunkTIME GetTime ()
 Gets image timestamp, TIME chunk
 
String GetTimeAsString ()
 Gets image timestamp, TIME chunk, as a String
 
PngChunkTextVar SetText (String key, String val, bool useLatin1, bool compress)
 Creates a text chunk and enqueues it
 
PngChunkTextVar SetText (String key, String val)
 Creates a plain text chunk (tEXT) and enqueues it
 
List< PngChunkTextVarGetTxtsForKey (String key)
 Retrieves all text chunks with a given key
 
String GetTxtForKey (String key)
 Joins all strings for a given key
 
PngChunkPLTE GetPLTE ()
 
PngChunkPLTE CreatePLTEChunk ()
 
PngChunkTRNS GetTRNS ()
 
PngChunkTRNS CreateTRNSChunk ()
 

Detailed Description

Image Metadata, wrapper over a ChunksList

Additional image info, apart from the ImageInfo and the pixels themselves. Includes Palette and ancillary chunks. This class provides a wrapper over the collection of chunks of a image (read or to write) and provides some high level methods to access them

Member Function Documentation

void Hjg.Pngcs.Chunks.PngMetadata.QueueChunk ( PngChunk  chunk,
bool  lazyOverwrite 
)

Queues the chunk at the writer

Parameters
chunkChunk, ready for write
lazyOverwriteOvewrite lazily equivalent chunks

Warning: the overwriting applies to equivalent chunks, see ChunkPredicateEquiv and will only make sense for queued (not yet writen) chunks

void Hjg.Pngcs.Chunks.PngMetadata.QueueChunk ( PngChunk  chunk)

Queues the chunk at the writer

Parameters
chunkChunk, ready for write
double [] Hjg.Pngcs.Chunks.PngMetadata.GetDpi ( )

Returns physical resolution, in DPI, in both coordinates

Returns
[dpix,dpiy], -1 if not set or unknown dimensions
void Hjg.Pngcs.Chunks.PngMetadata.SetDpi ( double  dpix,
double  dpiy 
)

Sets physical resolution, in DPI

This is a utility method that creates and enqueues a PHYS chunk

Parameters
dpixResolution in x
dpiyResolution in y
void Hjg.Pngcs.Chunks.PngMetadata.SetDpi ( double  dpi)

Sets physical resolution, in DPI, both value in x and y dimensions

This is a utility method that creates and enqueues a PHYS chunk

Parameters
dpiResolution in dpi
PngChunkTIME Hjg.Pngcs.Chunks.PngMetadata.SetTimeNow ( int  nsecs)

Creates a TIME chunk, nsecs in the past from now.

Parameters
nsecsSeconds in the past. If negative, it's a future time
Returns
The created and queued chunk
PngChunkTIME Hjg.Pngcs.Chunks.PngMetadata.SetTimeNow ( )

Creates a TIME chunk with current time.

Returns
The created and queued chunk
PngChunkTIME Hjg.Pngcs.Chunks.PngMetadata.SetTimeYMDHMS ( int  year,
int  mon,
int  day,
int  hour,
int  min,
int  sec 
)

Creates a TIME chunk with given date and time

Parameters
yearYear
monMonth (1-12)
dayDay of month (1-31)
hourHour (0-23)
minMinute (0-59)
secSeconds (0-59)
Returns
The created and queued chunk
PngChunkTIME Hjg.Pngcs.Chunks.PngMetadata.GetTime ( )

Gets image timestamp, TIME chunk

Returns
TIME chunk, null if not present
String Hjg.Pngcs.Chunks.PngMetadata.GetTimeAsString ( )

Gets image timestamp, TIME chunk, as a String

Returns
Formated TIME, empty string if not present
PngChunkTextVar Hjg.Pngcs.Chunks.PngMetadata.SetText ( String  key,
String  val,
bool  useLatin1,
bool  compress 
)

Creates a text chunk and enqueues it

Parameters
keyKey. Short and ASCII string
valText.
useLatin1Flag. If false, will use UTF-8 (iTXt)
compressFlag. Uses zTXt chunk.
Returns
The created and enqueued chunk
PngChunkTextVar Hjg.Pngcs.Chunks.PngMetadata.SetText ( String  key,
String  val 
)

Creates a plain text chunk (tEXT) and enqueues it

Parameters
keyKey
valText
Returns
The created and enqueued chunk
List<PngChunkTextVar> Hjg.Pngcs.Chunks.PngMetadata.GetTxtsForKey ( String  key)

Retrieves all text chunks with a given key

Parameters
keyKey
Returns
Empty list if nothing found

Can mix tEXt zTXt and iTXt chunks

String Hjg.Pngcs.Chunks.PngMetadata.GetTxtForKey ( String  key)

Joins all strings for a given key

Parameters
keyKey
Returns
Concatenated (with newlines) if several found, empty string if none

You'd perhaps prefer GetTxtsForKey

PngChunkPLTE Hjg.Pngcs.Chunks.PngMetadata.GetPLTE ( )
PngChunkPLTE Hjg.Pngcs.Chunks.PngMetadata.CreatePLTEChunk ( )
PngChunkTRNS Hjg.Pngcs.Chunks.PngMetadata.GetTRNS ( )

Returns the TRNS chunk, if present

Returns
null if not present
PngChunkTRNS Hjg.Pngcs.Chunks.PngMetadata.CreateTRNSChunk ( )

Creates a new empty TRNS chunk, queues it for write and return it to the caller, who should fill its entries