From 5b567683a71de6f168c12b97a7eddf12e95dfacb Mon Sep 17 00:00:00 2001 From: juliandescottes Date: Tue, 1 Dec 2015 14:17:26 +0100 Subject: [PATCH] Issue #357 : prevent transparency in GIF export if more than 256 colors --- .../controller/settings/exportimage/GifExportController.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/js/controller/settings/exportimage/GifExportController.js b/src/js/controller/settings/exportimage/GifExportController.js index 5c46e69b..16bb0464 100644 --- a/src/js/controller/settings/exportimage/GifExportController.js +++ b/src/js/controller/settings/exportimage/GifExportController.js @@ -94,7 +94,7 @@ }; ns.GifExportController.prototype.updatePreview_ = function (src) { - this.previewContainerEl.innerHTML = '
'; + this.previewContainerEl.innerHTML = '
'; }; ns.GifExportController.prototype.getZoom_ = function () { @@ -107,13 +107,16 @@ var preserveColors = currentColors.length < MAX_GIF_COLORS; var transparentColor = this.getTransparentColor(currentColors); + // transparency only supported if preserveColors is true, see Issue #357 + var transparent = preserveColors ? parseInt(transparentColor.substring(1), 16) : null; + var gif = new window.GIF({ workers: 5, quality: 1, width: this.piskelController.getWidth() * zoom, height: this.piskelController.getHeight() * zoom, preserveColors : preserveColors, - transparent : parseInt(transparentColor.substring(1), 16) + transparent : transparent }); for (var i = 0 ; i < this.piskelController.getFrameCount() ; i++) {