mirror of
https://github.com/danbulant/pngjs
synced 2026-07-08 04:30:33 +00:00
Gamma division constant
This commit is contained in:
parent
b24153494e
commit
79465895af
3 changed files with 5 additions and 3 deletions
|
|
@ -14,5 +14,7 @@ module.exports = {
|
||||||
|
|
||||||
COLOR_PALETTE: 1,
|
COLOR_PALETTE: 1,
|
||||||
COLOR_COLOR: 2,
|
COLOR_COLOR: 2,
|
||||||
COLOR_ALPHA: 4
|
COLOR_ALPHA: 4,
|
||||||
|
|
||||||
|
GAMMA_DIVISION: 100000
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ Packer.prototype._packChunk = function(type, data) {
|
||||||
|
|
||||||
Packer.prototype._packGAMA = function(gamma) {
|
Packer.prototype._packGAMA = function(gamma) {
|
||||||
var buf = new Buffer(4);
|
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);
|
return this._packChunk(constants.TYPE_gAMA, buf);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ Parser.prototype._handleGAMA = function(length) {
|
||||||
Parser.prototype._parseGAMA = function(data) {
|
Parser.prototype._parseGAMA = function(data) {
|
||||||
|
|
||||||
this._crc.write(data);
|
this._crc.write(data);
|
||||||
this.gamma(data.readUInt32BE(0) / 100000); //TODO constant
|
this.gamma(data.readUInt32BE(0) / constants.GAMMA_DIVISION);
|
||||||
|
|
||||||
this._handleChunkEnd();
|
this._handleChunkEnd();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue