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

Static utility methods for CHunks More...

Static Public Member Functions

static byte[] ToBytes (String x)
 Converts to bytes using Latin1 (ISO-8859-1)
 
static String ToString (byte[] x)
 Converts to String using Latin1 (ISO-8859-1)
 
static String ToString (byte[] x, int offset, int len)
 Converts to String using Latin1 (ISO-8859-1)
 
static byte[] ToBytesUTF8 (String x)
 Converts to bytes using UTF-8
 
static String ToStringUTF8 (byte[] x)
 Converts to string using UTF-8
 
static String ToStringUTF8 (byte[] x, int offset, int len)
 Converts to string using UTF-8
 
static void WriteBytesToStream (Stream stream, byte[] bytes)
 Writes full array of bytes to stream
 
static bool IsCritical (String id)
 Critical chunks: first letter is uppercase
 
static bool IsPublic (String id)
 Public chunks: second letter is uppercase
 
static bool IsSafeToCopy (String id)
 Safe to copy chunk: fourth letter is lower case
 
static bool IsUnknown (PngChunk chunk)
 We consider a chunk as "unknown" if our chunk factory (even when it has been augmented by client code) doesn't recognize it
 
static int PosNullByte (byte[] bytes)
 Finds position of null byte in array
 
static bool ShouldLoad (String id, ChunkLoadBehaviour behav)
 Decides if a chunk should be loaded, according to a ChunkLoadBehaviour
 
static List< PngChunkFilterList (List< PngChunk > list, ChunkPredicate predicateKeep)
 Filters a list of Chunks, keeping those which match the predicate
 
static int TrimList (List< PngChunk > list, ChunkPredicate predicateRemove)
 Filters a list of Chunks, removing those which match the predicate
 
static bool Equivalent (PngChunk c1, PngChunk c2)
 Ad-hoc criteria for 'equivalent' chunks.
 
static bool IsText (PngChunk c)
 

Detailed Description

Static utility methods for CHunks

Client code should rarely need this, see PngMetada and ChunksList

Member Function Documentation

static byte [] Hjg.Pngcs.Chunks.ChunkHelper.ToBytes ( String  x)
static

Converts to bytes using Latin1 (ISO-8859-1)

Parameters
x
Returns
static String Hjg.Pngcs.Chunks.ChunkHelper.ToString ( byte[]  x)
static

Converts to String using Latin1 (ISO-8859-1)

Parameters
x
Returns
static String Hjg.Pngcs.Chunks.ChunkHelper.ToString ( byte[]  x,
int  offset,
int  len 
)
static

Converts to String using Latin1 (ISO-8859-1)

Parameters
x
offset
len
Returns
static byte [] Hjg.Pngcs.Chunks.ChunkHelper.ToBytesUTF8 ( String  x)
static

Converts to bytes using UTF-8

Parameters
x
Returns
static String Hjg.Pngcs.Chunks.ChunkHelper.ToStringUTF8 ( byte[]  x)
static

Converts to string using UTF-8

Parameters
x
Returns
static String Hjg.Pngcs.Chunks.ChunkHelper.ToStringUTF8 ( byte[]  x,
int  offset,
int  len 
)
static

Converts to string using UTF-8

Parameters
x
offset
len
Returns
static void Hjg.Pngcs.Chunks.ChunkHelper.WriteBytesToStream ( Stream  stream,
byte[]  bytes 
)
static

Writes full array of bytes to stream

Parameters
stream
bytes
static bool Hjg.Pngcs.Chunks.ChunkHelper.IsCritical ( String  id)
static

Critical chunks: first letter is uppercase

Parameters
id
Returns
static bool Hjg.Pngcs.Chunks.ChunkHelper.IsPublic ( String  id)
static

Public chunks: second letter is uppercase

Parameters
id
Returns
static bool Hjg.Pngcs.Chunks.ChunkHelper.IsSafeToCopy ( String  id)
static

Safe to copy chunk: fourth letter is lower case

Parameters
id
Returns
static bool Hjg.Pngcs.Chunks.ChunkHelper.IsUnknown ( PngChunk  chunk)
static

We consider a chunk as "unknown" if our chunk factory (even when it has been augmented by client code) doesn't recognize it

Parameters
chunk
Returns
static int Hjg.Pngcs.Chunks.ChunkHelper.PosNullByte ( byte[]  bytes)
static

Finds position of null byte in array

Parameters
bytes
Returns
-1 if not found
static bool Hjg.Pngcs.Chunks.ChunkHelper.ShouldLoad ( String  id,
ChunkLoadBehaviour  behav 
)
static

Decides if a chunk should be loaded, according to a ChunkLoadBehaviour

Parameters
id
behav
Returns
static List<PngChunk> Hjg.Pngcs.Chunks.ChunkHelper.FilterList ( List< PngChunk list,
ChunkPredicate  predicateKeep 
)
static

Filters a list of Chunks, keeping those which match the predicate

The original list is not altered

Parameters
list
predicateKeep
Returns
static int Hjg.Pngcs.Chunks.ChunkHelper.TrimList ( List< PngChunk list,
ChunkPredicate  predicateRemove 
)
static

Filters a list of Chunks, removing those which match the predicate

The original list is not altered

Parameters
list
predicateRemove
Returns
static bool Hjg.Pngcs.Chunks.ChunkHelper.Equivalent ( PngChunk  c1,
PngChunk  c2 
)
static

Ad-hoc criteria for 'equivalent' chunks.

Two chunks are equivalent if they have the same Id AND either: 1. they are Single 2. both are textual and have the same key 3. both are SPLT and have the same palette name Bear in mind that this is an ad-hoc, non-standard, nor required (nor wrong) criterion. Use it only if you find it useful. Notice that PNG allows to have repeated textual keys with same keys.

Parameters
c1Chunk1
c2Chunk1
Returns
true if equivalent
static bool Hjg.Pngcs.Chunks.ChunkHelper.IsText ( PngChunk  c)
static