From bd85fc084a22f0edf806ef8afcb175c65c813f58 Mon Sep 17 00:00:00 2001 From: Abdi Dahir Date: Mon, 17 Nov 2014 20:55:26 -0500 Subject: [PATCH 1/3] Wiping blue's from pngs with no transparency. Probably better to not use transparency length to determine ret array size but incase it was used for something I left it in there. It needs to be shifted when there is no transparency however, otherwise the blues get wiped from output png. --- png.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/png.js b/png.js index 442bba5..65f3088 100644 --- a/png.js +++ b/png.js @@ -301,7 +301,7 @@ var c, i, length, palette, pos, ret, transparency, _i, _ref, _ref1; palette = this.palette; transparency = this.transparency.indexed || []; - ret = new Uint8Array((transparency.length || 0) + palette.length); + ret = new Uint8Array((transparency.length || 255) + palette.length); pos = 0; length = palette.length; c = 0; From 0009152fd481fdc61cea009204317dad6054fd67 Mon Sep 17 00:00:00 2001 From: Abdi Dahir Date: Mon, 17 Nov 2014 23:14:07 -0500 Subject: [PATCH 2/3] err 256* --- png.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/png.js b/png.js index 65f3088..6d2ac58 100644 --- a/png.js +++ b/png.js @@ -301,7 +301,7 @@ var c, i, length, palette, pos, ret, transparency, _i, _ref, _ref1; palette = this.palette; transparency = this.transparency.indexed || []; - ret = new Uint8Array((transparency.length || 255) + palette.length); + ret = new Uint8Array((transparency.length || 256) + palette.length); pos = 0; length = palette.length; c = 0; From 135a5bf8400a52617d33ded028ca6fc30aa47284 Mon Sep 17 00:00:00 2001 From: Abdi Dahir Date: Tue, 18 Nov 2014 00:11:25 -0500 Subject: [PATCH 3/3] magic number change incase of 16bit channel values, keep transparency size equal to the channel size. --- png.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/png.js b/png.js index 6d2ac58..2060ee9 100644 --- a/png.js +++ b/png.js @@ -301,7 +301,7 @@ var c, i, length, palette, pos, ret, transparency, _i, _ref, _ref1; palette = this.palette; transparency = this.transparency.indexed || []; - ret = new Uint8Array((transparency.length || 256) + palette.length); + ret = new Uint8Array((transparency.length || palette.length/3) + palette.length); pos = 0; length = palette.length; c = 0;