Updates jpgjs libary to the latest: component order fix

This commit is contained in:
Yury Delendik 2012-04-28 08:59:05 -05:00
parent ba9c828117
commit 244ce870c3

20
external/jpgjs/jpg.js vendored
View File

@ -637,7 +637,10 @@ var JpegImage = (function jpegImage() {
tableData[z] = data[offset++];
}
} else if ((quantizationTableSpec >> 4) === 1) { //16 bit
tableData[j] = readUint16();
for (j = 0; j < 64; j++) {
var z = dctZigZag[j];
tableData[z] = readUint16();
}
} else
throw "DQT: invalid table spec";
quantizationTables[quantizationTableSpec & 15] = tableData;
@ -652,7 +655,8 @@ var JpegImage = (function jpegImage() {
frame.precision = data[offset++];
frame.scanLines = readUint16();
frame.samplesPerLine = readUint16();
frame.components = [];
frame.components = {};
frame.componentsOrder = [];
var componentsCount = data[offset++], componentId;
var maxH = 0, maxV = 0;
for (i = 0; i < componentsCount; i++) {
@ -660,6 +664,7 @@ var JpegImage = (function jpegImage() {
var h = data[offset + 1] >> 4;
var v = data[offset + 1] & 15;
var qId = data[offset + 2];
frame.componentsOrder.push(componentId);
frame.components[componentId] = {
h: h,
v: v,
@ -728,15 +733,14 @@ var JpegImage = (function jpegImage() {
this.jfif = jfif;
this.adobe = adobe;
this.components = [];
for (var id in frame.components) {
if (frame.components.hasOwnProperty(id)) {
for (var i = 0; i < frame.componentsOrder.length; i++) {
var component = frame.components[frame.componentsOrder[i]];
this.components.push({
lines: buildComponentData(frame, frame.components[id]),
scaleX: frame.components[id].h / frame.maxH,
scaleY: frame.components[id].v / frame.maxV
lines: buildComponentData(frame, component),
scaleX: component.h / frame.maxH,
scaleY: component.v / frame.maxV
});
}
}
},
getData: function getData(width, height) {
function clampTo8bit(a) {