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 - .dataChunks :
Array.<Uint8Array> - .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(chunk)
- .decodeIDAT()
- .decodeTRNS(chunk)
- .decodeIEND()
- .decodePixels()
- .interlaceNone(data)
- .interlaceAdam7(data)
- .unFilter(filter_type, data, scanline_address, output, bytes_per_pixel, output_offset, output_offset_previous, length)
- .unFilterNone(data, scanline_address, output, bytes_per_pixel, output_offset, output_offset_previous, length)
- .unFilterSub(scanline, scanline_offset, pixels, bpp, offset, output_offset_previous, length)
- .unFilterUp(scanline, scanline_offset, pixels, bpp, offset, output_offset_previous, length)
- .unFilterAverage(scanline, scanline_offset, pixels, bpp, offset, output_offset_previous, length)
- .unFilterPaeth(scanline, scanline_offset, pixels, bpp, offset, output_offset_previous, length)
- .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.dataChunks : Array.<Uint8Array>
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(chunk)
http://www.w3.org/TR/PNG/#11PLTE
Kind: instance method of PNGReader
| Param | Type |
|---|---|
| chunk | Uint8Array |
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.unFilter(filter_type, data, scanline_address, output, bytes_per_pixel, output_offset, output_offset_previous, length)
Kind: instance method of PNGReader
See: https://www.w3.org/TR/PNG-Filters.html
| Param | Type | Description |
|---|---|---|
| filter_type | number | |
| data | Uint8Array | |
| scanline_address | number | |
| output | Uint8Array | |
| bytes_per_pixel | number | |
| output_offset | number | |
| output_offset_previous | number | where does result of previous scanline begin in the output? Needed for various filters such as Up |
| length | number |
pngReader.unFilterNone(data, scanline_address, output, bytes_per_pixel, output_offset, output_offset_previous, length)
With the None filter, the scanline is transmitted unmodified; it is only necessary to insert a filter type byte before the data.
Kind: instance method of PNGReader
See: https://www.w3.org/TR/PNG-Filters.html
| Param | Type |
|---|---|
| data | Uint8Array |
| scanline_address | number |
| output | Uint8Array |
| bytes_per_pixel | number |
| output_offset | number |
| output_offset_previous | number |
| length | number |
pngReader.unFilterSub(scanline, scanline_offset, pixels, bpp, offset, output_offset_previous, length)
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
See: https://www.w3.org/TR/PNG-Filters.html
| Param | Type | Description |
|---|---|---|
| scanline | Uint8Array | raw data |
| scanline_offset | number | |
| pixels | Uint8Array | processed output |
| bpp | number | bytes-per-pixel |
| offset | number | |
| output_offset_previous | number | |
| length | number |
pngReader.unFilterUp(scanline, scanline_offset, pixels, bpp, offset, output_offset_previous, length)
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
See: https://www.w3.org/TR/PNG-Filters.html
| Param | Type | Description |
|---|---|---|
| scanline | Uint8Array | raw data |
| scanline_offset | number | |
| pixels | Uint8Array | processed output |
| bpp | number | bytes-per-pixel |
| offset | number | |
| output_offset_previous | number | |
| length | number |
pngReader.unFilterAverage(scanline, scanline_offset, pixels, bpp, offset, output_offset_previous, length)
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
See: https://www.w3.org/TR/PNG-Filters.html
| Param | Type | Description |
|---|---|---|
| scanline | Uint8Array | raw data |
| scanline_offset | number | |
| pixels | Uint8Array | processed output |
| bpp | number | bytes-per-pixel |
| offset | number | |
| output_offset_previous | number | |
| length | number |
pngReader.unFilterPaeth(scanline, scanline_offset, pixels, bpp, offset, output_offset_previous, length)
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.
Kind: instance method of PNGReader
See: https://www.w3.org/TR/PNG-Filters.html
| Param | Type | Description |
|---|---|---|
| scanline | Uint8Array | raw data |
| scanline_offset | number | |
| pixels | Uint8Array | processed output |
| bpp | number | bytes-per-pixel |
| offset | number | |
| output_offset_previous | number | |
| length | number |
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 |