diff --git a/jpg.js b/jpg.js index 89d0669..e60f8df 100644 --- a/jpg.js +++ b/jpg.js @@ -508,7 +508,7 @@ var JpegImage = (function jpegImage() { // convert to 8-bit integers for (i = 0; i < 64; ++i) { var index = blockBufferOffset + i; - var q = p[i]; + var q = Math.floor(p[i]*component.bitConversion); q = (q <= -2056) ? 0 : (q >= 2024) ? 255 : (q + 2056) >> 4; component.blockData[index] = q; } @@ -711,7 +711,9 @@ var JpegImage = (function jpegImage() { var l = frame.components.push({ h: h, v: v, - quantizationTable: quantizationTables[qId] + quantizationTable: quantizationTables[qId], + quantizationTableId: qId, + bitConversion:255/((1<