geotiff.js is a small library to parse TIFF files for visualization or analysis. It is written in pure JavaScript, and is usable in both the browser and node.js applications.
For each loaded tile, this line in _readRaster copies every image pixel from the tile buffer one-by-one. Each of our tiles (1024px by 1024px) therefore call this function over a million times when loaded. For our case of direct rendering of hundreds of tiles, This produces a 4x slowdown compared to a direct copy from tile buffer to typed array.
What I expect
Only one buffer to array conversion should be needed to read one tile that byte-for-byte matches an IFD.
What I observe
For each loaded tile, this line in _readRaster copies every image pixel from the tile buffer one-by-one. Each of our tiles (1024px by 1024px) therefore call this function over a million times when loaded. For our case of direct rendering of hundreds of tiles, This produces a 4x slowdown compared to a direct copy from tile buffer to typed array.
What I expect
Only one buffer to array conversion should be needed to read one tile that byte-for-byte matches an IFD.
Proposed solution
PR #348