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