From bdc384e9c3339a4155df3cf4dc8fe99669a1ce75 Mon Sep 17 00:00:00 2001 From: Jesus Nuevo Date: Wed, 15 Nov 2017 17:47:10 +1100 Subject: [PATCH] Fixes for #88 and #93 (#94) --- lib/bitpacker.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bitpacker.js b/lib/bitpacker.js index 219380f..05d9bd9 100644 --- a/lib/bitpacker.js +++ b/lib/bitpacker.js @@ -22,6 +22,7 @@ module.exports = function(dataIn, width, height, options) { var maxValue = 255; var inBpp = constants.COLORTYPE_TO_BPP_MAP[options.inputColorType]; + if (inBpp == 4 && !options.inputHasAlpha) inBpp = 3; var outBpp = constants.COLORTYPE_TO_BPP_MAP[options.colorType]; if (options.bitDepth === 16) { maxValue = 65535; @@ -80,7 +81,7 @@ module.exports = function(dataIn, width, height, options) { blue = Math.min(Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0), maxValue); } } - return {red, green, blue, alpha}; + return {red: red, green: green, blue: blue, alpha: alpha}; } for (var y = 0; y < height; y++) {