fix #621 : allow color worker to detect up to 256 colors

This commit is contained in:
juliandescottes 2017-01-25 15:07:55 +01:00
parent dc149f88d6
commit ba779a97a6
3 changed files with 6 additions and 3 deletions

View File

@ -13,6 +13,9 @@ var Constants = {
MAX_WIDTH : 1024,
MAX_PALETTE_COLORS : 100,
// allow current colors service to get up to 256 colors.
// GIF generation is different if the color count goes over 256.
MAX_WORKER_COLORS : 256,
PREVIEW_FILM_SIZE : 96,
ANIMATED_PREVIEW_WIDTH : 200,

View File

@ -15,7 +15,7 @@
ns.FrameColors.prototype.process = function () {
this.worker.postMessage([
pskl.utils.colorToInt(Constants.TRANSPARENT_COLOR),
Constants.MAX_PALETTE_COLORS, this.pixels
Constants.MAX_WORKER_COLORS, this.pixels
]);
};

View File

@ -49,7 +49,7 @@
var frameColors = {};
var transparentColorInt = this.TRANSPARENT_COLOR;
var colors = 0;
for (var i = 0, length = frame.length; i < length && colors < this.MAX_PALETTE_COLORS; i++) {
for (var i = 0, length = frame.length; i < length && colors < this.MAX_WORKER_COLORS; i++) {
var color = frame[i];
if (color !== transparentColorInt) {
if (!frameColors[color]) {
@ -64,7 +64,7 @@
this.onmessage = function(event) {
try {
this.TRANSPARENT_COLOR = event.data[0];
this.MAX_PALETTE_COLORS = event.data[1];
this.MAX_WORKER_COLORS = event.data[1];
var frame = event.data[2];
var colors = getFrameColors(frame);
this.postMessage({