From 79465895afafff520c7d6708653ac810916cb309 Mon Sep 17 00:00:00 2001 From: Luke Page Date: Thu, 6 Aug 2015 18:50:36 +0100 Subject: [PATCH] Gamma division constant --- lib/constants.js | 4 +++- lib/packer.js | 2 +- lib/parser.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/constants.js b/lib/constants.js index 7d52443..96af8eb 100755 --- a/lib/constants.js +++ b/lib/constants.js @@ -14,5 +14,7 @@ module.exports = { COLOR_PALETTE: 1, COLOR_COLOR: 2, - COLOR_ALPHA: 4 + COLOR_ALPHA: 4, + + GAMMA_DIVISION: 100000 }; diff --git a/lib/packer.js b/lib/packer.js index 325c83d..0960523 100755 --- a/lib/packer.js +++ b/lib/packer.js @@ -76,7 +76,7 @@ Packer.prototype._packChunk = function(type, data) { Packer.prototype._packGAMA = function(gamma) { var buf = new Buffer(4); - buf.writeUInt32BE(Math.floor(gamma * 100000), 0); // TODO constant + buf.writeUInt32BE(Math.floor(gamma * constants.GAMMA_DIVISION), 0); return this._packChunk(constants.TYPE_gAMA, buf); }; diff --git a/lib/parser.js b/lib/parser.js index 500f05f..2eddfaf 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -249,7 +249,7 @@ Parser.prototype._handleGAMA = function(length) { Parser.prototype._parseGAMA = function(data) { this._crc.write(data); - this.gamma(data.readUInt32BE(0) / 100000); //TODO constant + this.gamma(data.readUInt32BE(0) / constants.GAMMA_DIVISION); this._handleChunkEnd(); };