Comparing version 0.2.0 to 0.3.0
@@ -203,2 +203,3 @@ /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- / | ||
var z = dctZigZag[k]; | ||
var direction = zz[z] < 0 ? -1 : 1; | ||
switch (successiveACState) { | ||
@@ -226,3 +227,3 @@ case 0: // initial state | ||
if (zz[z]) | ||
zz[z] += (readBit() << successive); | ||
zz[z] += (readBit() << successive) * direction; | ||
else { | ||
@@ -236,3 +237,3 @@ r--; | ||
if (zz[z]) | ||
zz[z] += (readBit() << successive); | ||
zz[z] += (readBit() << successive) * direction; | ||
else { | ||
@@ -245,3 +246,3 @@ zz[z] = successiveACNextValue << successive; | ||
if (zz[z]) | ||
zz[z] += (readBit() << successive); | ||
zz[z] += (readBit() << successive) * direction; | ||
break; | ||
@@ -722,3 +723,3 @@ } | ||
((huffmanTableSpec >> 4) === 0 ? | ||
((huffmanTableSpec >> 4) === 0 ? | ||
huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = | ||
@@ -725,0 +726,0 @@ buildHuffmanTable(codeLengths, huffmanValues); |
{ | ||
"name": "jpeg-js", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "A pure javascript JPEG encoder and decoder", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,3 +25,3 @@ # jpeg-js | ||
var rawImageData = jpeg.decode(jpegData); | ||
console.log(jpegData.data); | ||
console.log(rawImageData); | ||
/* | ||
@@ -41,3 +41,3 @@ { width: 320, | ||
var rawImageData = jpeg.decode(jpegData, true); // return as Uint8Array | ||
console.log(jpegData.data); | ||
console.log(rawImageData); | ||
/* | ||
@@ -44,0 +44,0 @@ { width: 320, |
@@ -107,2 +107,25 @@ var redtape = require('redtape'), | ||
it('should be able to decode a progressive JPEG', function(t) { | ||
var jpegData = fixture('skater-progressive.jpg'); | ||
var rawImageData = jpeg.decode(jpegData); | ||
t.equal(rawImageData.width, 256); | ||
t.equal(rawImageData.height, 256); | ||
var expected = fixture('skater-progressive.rgba'); | ||
t.deepEqual(rawImageData.data, expected); | ||
t.end(); | ||
}); | ||
it('should be able to decode a progressive JPEG the same as non-progressive', function(t) { | ||
var jpegData = fixture('skater.jpg'); | ||
var rawImageData = jpeg.decode(jpegData); | ||
var otherJpegData = fixture('skater-progressive.jpg'); | ||
var otherRawImageData = jpeg.decode(otherJpegData); | ||
t.equal(rawImageData.width, otherRawImageData.width); | ||
t.equal(rawImageData.height, otherRawImageData.height); | ||
t.deepEqual(rawImageData.data, otherRawImageData.data); | ||
t.end(); | ||
}); | ||
it('should be able to encode a JPEG', function (t) { | ||
@@ -109,0 +132,0 @@ var frameData = fixture('grumpycat.rgba'); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4847273
32
1769