C# Класс Hjg.Pngcs.Chunks.ChunkHelper

Static utility methods for CHunks
Client code should rarely need this, see PngMetada and ChunksList
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
Equivalent ( PngChunk c1, PngChunk c2 ) : bool

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.

FilterList ( List list, ChunkPredicate predicateKeep ) : List

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

The original list is not altered

IsCritical ( String id ) : bool

Critical chunks: first letter is uppercase

IsPublic ( String id ) : bool

Public chunks: second letter is uppercase

IsSafeToCopy ( String id ) : bool

Safe to copy chunk: fourth letter is lower case

IsText ( PngChunk c ) : bool
IsUnknown ( PngChunk chunk ) : bool

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

PosNullByte ( byte bytes ) : int

Finds position of null byte in array

ShouldLoad ( String id, ChunkLoadBehaviour behav ) : bool

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

ToBytes ( String x ) : byte[]

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

ToBytesUTF8 ( String x ) : byte[]

Converts to bytes using UTF-8

ToString ( byte x ) : String

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

ToString ( byte x, int offset, int len ) : String

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

ToStringUTF8 ( byte x ) : String

Converts to string using UTF-8

ToStringUTF8 ( byte x, int offset, int len ) : String

Converts to string using UTF-8

TrimList ( List list, ChunkPredicate predicateRemove ) : int

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

The original list is not altered

WriteBytesToStream ( Stream stream, byte bytes ) : void

Writes full array of bytes to stream

Приватные методы

Метод Описание
compressBytes ( byte ori, bool compress ) : byte[]
compressBytes ( byte ori, int offset, int len, bool compress ) : byte[]
maskMatch ( int v, int mask ) : bool
shovelInToOut ( Stream inx, Stream outx ) : void

Описание методов

Equivalent() публичный статический Метод

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.
public static Equivalent ( PngChunk c1, PngChunk c2 ) : bool
c1 PngChunk Chunk1
c2 PngChunk Chunk1
Результат bool

FilterList() публичный статический Метод

Filters a list of Chunks, keeping those which match the predicate
The original list is not altered
public static FilterList ( List list, ChunkPredicate predicateKeep ) : List
list List
predicateKeep ChunkPredicate
Результат List

IsCritical() публичный статический Метод

Critical chunks: first letter is uppercase
public static IsCritical ( String id ) : bool
id String
Результат bool

IsPublic() публичный статический Метод

Public chunks: second letter is uppercase
public static IsPublic ( String id ) : bool
id String
Результат bool

IsSafeToCopy() публичный статический Метод

Safe to copy chunk: fourth letter is lower case
public static IsSafeToCopy ( String id ) : bool
id String
Результат bool

IsText() публичный статический Метод

public static IsText ( PngChunk c ) : bool
c PngChunk
Результат bool

IsUnknown() публичный статический Метод

We consider a chunk as "unknown" if our chunk factory (even when it has been augmented by client code) doesn't recognize it
public static IsUnknown ( PngChunk chunk ) : bool
chunk PngChunk
Результат bool

PosNullByte() публичный статический Метод

Finds position of null byte in array
public static PosNullByte ( byte bytes ) : int
bytes byte
Результат int

ShouldLoad() публичный статический Метод

Decides if a chunk should be loaded, according to a ChunkLoadBehaviour
public static ShouldLoad ( String id, ChunkLoadBehaviour behav ) : bool
id String
behav ChunkLoadBehaviour
Результат bool

ToBytes() публичный статический Метод

Converts to bytes using Latin1 (ISO-8859-1)
public static ToBytes ( String x ) : byte[]
x String
Результат byte[]

ToBytesUTF8() публичный статический Метод

Converts to bytes using UTF-8
public static ToBytesUTF8 ( String x ) : byte[]
x String
Результат byte[]

ToString() публичный статический Метод

Converts to String using Latin1 (ISO-8859-1)
public static ToString ( byte x ) : String
x byte
Результат String

ToString() публичный статический Метод

Converts to String using Latin1 (ISO-8859-1)
public static ToString ( byte x, int offset, int len ) : String
x byte
offset int
len int
Результат String

ToStringUTF8() публичный статический Метод

Converts to string using UTF-8
public static ToStringUTF8 ( byte x ) : String
x byte
Результат String

ToStringUTF8() публичный статический Метод

Converts to string using UTF-8
public static ToStringUTF8 ( byte x, int offset, int len ) : String
x byte
offset int
len int
Результат String

TrimList() публичный статический Метод

Filters a list of Chunks, removing those which match the predicate
The original list is not altered
public static TrimList ( List list, ChunkPredicate predicateRemove ) : int
list List
predicateRemove ChunkPredicate
Результат int

WriteBytesToStream() публичный статический Метод

Writes full array of bytes to stream
public static WriteBytesToStream ( Stream stream, byte bytes ) : void
stream Stream
bytes byte
Результат void