Merge pull request #359 from juliandescottes/gif-transparency-bug

Issue #357 : prevent transparency in GIF export if more than 256 colors
This commit is contained in:
Julian Descottes 2015-12-01 14:35:04 +01:00
commit e1592a8ace

View File

@ -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++) {