foliojs / png.js

A (animated) PNG decoder in JavaScript for the HTML5 canvas element and Node.js
http://devongovett.github.com/png.js
MIT License
489 stars 92 forks source link

Indexed png transparency increased to incorrrect length of 255 #16

Open jamesbrobb opened 10 years ago

jamesbrobb commented 10 years ago

Hi,

in png.js at line 135 you're incorrectly lengthening transparency.indexed to 255, if it's shorter.

The max length of that array should actually be the length of the palette divided by 3. And if it's parsed and is any longer there should be an error.

So it should read,

short = (this.palette.length/3) - this.transparency.indexed.length;