Issue #357 : prevent transparency in GIF export if more than 256 colors

This commit is contained in:
juliandescottes 2015-12-01 14:17:26 +01:00
parent 4d8b093941
commit 5b567683a7

View File

@ -94,7 +94,7 @@
}; };
ns.GifExportController.prototype.updatePreview_ = function (src) { ns.GifExportController.prototype.updatePreview_ = function (src) {
this.previewContainerEl.innerHTML = '<div><img style="max-width:32px;"src="' + src + '"/></div>'; this.previewContainerEl.innerHTML = '<div><img style="max-width:32px;" src="' + src + '"/></div>';
}; };
ns.GifExportController.prototype.getZoom_ = function () { ns.GifExportController.prototype.getZoom_ = function () {
@ -107,13 +107,16 @@
var preserveColors = currentColors.length < MAX_GIF_COLORS; var preserveColors = currentColors.length < MAX_GIF_COLORS;
var transparentColor = this.getTransparentColor(currentColors); 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({ var gif = new window.GIF({
workers: 5, workers: 5,
quality: 1, quality: 1,
width: this.piskelController.getWidth() * zoom, width: this.piskelController.getWidth() * zoom,
height: this.piskelController.getHeight() * zoom, height: this.piskelController.getHeight() * zoom,
preserveColors : preserveColors, preserveColors : preserveColors,
transparent : parseInt(transparentColor.substring(1), 16) transparent : transparent
}); });
for (var i = 0 ; i < this.piskelController.getFrameCount() ; i++) { for (var i = 0 ; i < this.piskelController.getFrameCount() ; i++) {