PNGReader
Classes
Functions
- inflate(encoded_chunk) ⇒
ArrayBuffer
- readUInt32(buffer, offset) ⇒
number
- readUInt8(buffer, offset) ⇒
number
PNGReader
Kind: global class
- PNGReader
- new exports.PNGReader(bytes)
- .i :
number
- .bytes :
Uint8Array
- .png :
PNG
- .buffer :
BinaryBuffer
- .crc_enabled :
boolean
- .header :
Uint8Array
- .readBytes(length) ⇒
Uint8Array
- .decodeHeader()
- .decodeChunk() ⇒
string
- ~chunk :
Uint8Array
- ~chunk :
- .decodesRGB(chunk)
- .decodetIME(chunk)
- .decodeiTXt(chunk)
- .decodezTXt(chunk)
- .decodetEXt(chunk)
- .decodeiEXt(chunk)
- .decodeIHDR()
- .decodePLTE()
- .decodeIDAT()
- .decodeTRNS(chunk)
- .decodeIEND()
- .decodePixels()
- .interlaceNone(data)
- .interlaceAdam7(data)
- .unFilterSub()
- .unFilterUp()
- .unFilterAverage()
- .unFilterPaeth()
- .parse() ⇒
PNG
new exports.PNGReader(bytes)
Param | Type |
---|---|
bytes | ArrayBuffer |
pngReader.i : number
current pointer
Kind: instance property of PNGReader
pngReader.bytes : Uint8Array
bytes buffer
Kind: instance property of PNGReader
pngReader.png : PNG
Output object
Kind: instance property of PNGReader
pngReader.buffer : BinaryBuffer
Kind: instance property of PNGReader
pngReader.crc_enabled : boolean
Whether CRC should be performed or not
Kind: instance property of PNGReader
pngReader.header : Uint8Array
Kind: instance property of PNGReader
pngReader.readBytes(length) ⇒ Uint8Array
Kind: instance method of PNGReader
Param | Type |
---|---|
length | number |
pngReader.decodeHeader()
http://www.w3.org/TR/2003/REC-PNG-20031110/#5PNG-file-signature
Kind: instance method of PNGReader
pngReader.decodeChunk() ⇒ string
http://www.w3.org/TR/2003/REC-PNG-20031110/#5Chunk-layout
length = 4 bytes type = 4 bytes (IHDR, PLTE, IDAT, IEND or others) chunk = length bytes crc = 4 bytes
Kind: instance method of PNGReader
Returns: string
- chunk type
decodeChunk~chunk : Uint8Array
Kind: inner constant of decodeChunk
pngReader.decodesRGB(chunk)
https://www.w3.org/TR/2003/REC-PNG-20031110/#11sRGB
Kind: instance method of PNGReader
Param | Type |
---|---|
chunk | Uint8Array |
pngReader.decodetIME(chunk)
https://www.w3.org/TR/2003/REC-PNG-20031110/#11tIME
Kind: instance method of PNGReader
Param | Type |
---|---|
chunk | Uint8Array |
pngReader.decodeiTXt(chunk)
International textual data
Kind: instance method of PNGReader
See: https://www.w3.org/TR/2003/REC-PNG-20031110/
Param | Type |
---|---|
chunk | Uint8Array |
pngReader.decodezTXt(chunk)
Compressed textual data
Kind: instance method of PNGReader
See: https://www.w3.org/TR/2003/REC-PNG-20031110/#11zTXt
Param | Type |
---|---|
chunk | Uint8Array |
pngReader.decodetEXt(chunk)
https://www.w3.org/TR/PNG/#11tEXt
Kind: instance method of PNGReader
Param | Type |
---|---|
chunk | Uint8Array |
pngReader.decodeiEXt(chunk)
NOTE: untested https://www.w3.org/TR/PNG/#11iEXt
Kind: instance method of PNGReader
Param | Type |
---|---|
chunk | Uint8Array |
pngReader.decodeIHDR()
http://www.w3.org/TR/2003/REC-PNG-20031110/#11IHDR http://www.libpng.org/pub/png/spec/1.2/png-1.2-pdg.html#C.IHDR
Width 4 bytes Height 4 bytes Bit depth 1 byte Colour type 1 byte Compression method 1 byte Filter method 1 byte Interlace method 1 byte
Kind: instance method of PNGReader
pngReader.decodePLTE()
http://www.w3.org/TR/PNG/#11PLTE
Kind: instance method of PNGReader
pngReader.decodeIDAT()
http://www.w3.org/TR/2003/REC-PNG-20031110/#11IDAT
Kind: instance method of PNGReader
pngReader.decodeTRNS(chunk)
https://www.w3.org/TR/PNG/#11tRNS
Kind: instance method of PNGReader
Param | Type |
---|---|
chunk | Uint8Array |
pngReader.decodeIEND()
http://www.w3.org/TR/2003/REC-PNG-20031110/#11IEND
Kind: instance method of PNGReader
pngReader.decodePixels()
Uncompress IDAT chunks
Kind: instance method of PNGReader
pngReader.interlaceNone(data)
Kind: instance method of PNGReader
Param | Type |
---|---|
data | Uint8Array |
pngReader.interlaceAdam7(data)
De-interlace image according to Adam 7 scheme
Kind: instance method of PNGReader
Param | Type |
---|---|
data | Uint8Array |
pngReader.unFilterSub()
The Sub() filter transmits the difference between each byte and the value of the corresponding byte of the prior pixel. Sub(x) = Raw(x) + Raw(x - bpp)
Kind: instance method of PNGReader
pngReader.unFilterUp()
The Up() filter is just like the Sub() filter except that the pixel immediately above the current pixel, rather than just to its left, is used as the predictor. Up(x) = Raw(x) + Prior(x)
Kind: instance method of PNGReader
pngReader.unFilterAverage()
The Average() filter uses the average of the two neighboring pixels (left and above) to predict the value of a pixel. Average(x) = Raw(x) + floor((Raw(x-bpp)+Prior(x))/2)
Kind: instance method of PNGReader
pngReader.unFilterPaeth()
The Paeth() filter computes a simple linear function of the three neighboring pixels (left, above, upper left), then chooses as predictor the neighboring pixel closest to the computed value. This technique is due to Alan W. Paeth. Paeth(x) = Raw(x) + PaethPredictor(Raw(x-bpp), Prior(x), Prior(x-bpp)) function PaethPredictor (a, b, c) begin ; a = left, b = above, c = upper left p := a + b - c ; initial estimate pa := abs(p - a) ; distances to a, b, c pb := abs(p - b) pc := abs(p - c) ; return nearest of a,b,c, ; breaking ties in order a,b,c. if pa <= pb AND pa <= pc then return a else if pb <= pc then return b else return c end
Kind: instance method of PNGReader
pngReader.parse() ⇒ PNG
Parse the PNG file
Kind: instance method of PNGReader
inflate(encoded_chunk) ⇒ ArrayBuffer
Kind: global function
Param | Type |
---|---|
encoded_chunk | Uint8Array |
readUInt32(buffer, offset) ⇒ number
Kind: global function
Param | Type |
---|---|
buffer | Uint8Array |
offset | number |
readUInt8(buffer, offset) ⇒ number
Kind: global function
Param | Type |
---|---|
buffer | Uint8Array |
offset | number |