image-js / fast-png

PNG image decoder and encoder written entirely in JavaScript
MIT License
329 stars 17 forks source link

Optimize PNGEncoder's writeDataBytes method #15

Closed p01 closed 3 years ago

p01 commented 3 years ago

Use IOBuffer.writeBytes method + a TypedArray view into the source data to write the whole line and avoid additional calls to IOBUffer's ensureAvailable and _updateLastWrittenByte methods

p01 commented 3 years ago

Oh... after running some benchmark encoding 350 PNGs from 256x256 to ~8000x4000 the initial implementation comes out faster. That will teach me 😛