diff --git a/bower.json b/bower.json index f5448e966..0ce428dcf 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.288", + "version": "1.0.291", "keywords": [ "Mozilla", "pdf", diff --git a/build/pdf.combined.js b/build/pdf.combined.js index 2393e1d30..4eddadf05 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.288'; -PDFJS.build = '2449142'; +PDFJS.version = '1.0.291'; +PDFJS.build = 'e03ac80'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -40652,9 +40652,27 @@ var JpegStream = (function JpegStreamClosure() { } try { var jpegImage = new JpegImage(); - if (this.colorTransform != -1) { - jpegImage.colorTransform = this.colorTransform; + + // checking if values needs to be transformed before conversion + if (this.dict && isArray(this.dict.get('Decode'))) { + var decodeArr = this.dict.get('Decode'); + var bitsPerComponent = this.dict.get('BitsPerComponent') || 8; + var decodeArrLength = decodeArr.length; + var transform = new Int32Array(decodeArrLength); + var transformNeeded = false; + var maxValue = (1 << bitsPerComponent) - 1; + for (var i = 0; i < decodeArrLength; i += 2) { + transform[i] = ((decodeArr[i + 1] - decodeArr[i]) * 256) | 0; + transform[i + 1] = (decodeArr[i] * maxValue) | 0; + if (transform[i] !== 256 || transform[i + 1] !== 0) { + transformNeeded = true; + } + } + if (transformNeeded) { + jpegImage.decodeTransform = transform; + } } + jpegImage.parse(this.bytes); var data = jpegImage.getData(this.drawWidth, this.drawHeight, /* forceRGBoutput = */true); @@ -43573,7 +43591,7 @@ var JpegImage = (function jpegImage() { var scaleX = this.width / width, scaleY = this.height / height; var component, componentScaleX, componentScaleY, blocksPerScanline; - var x, y, i, j; + var x, y, i, j, k; var index; var offset = 0; var output; @@ -43605,6 +43623,17 @@ var JpegImage = (function jpegImage() { } } } + + // decodeTransform will contains pairs of multiplier (-256..256) and + // additive + var transform = this.decodeTransform; + if (transform) { + for (i = 0; i < dataLength;) { + for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) { + data[i] = ((data[i] * transform[k]) >> 8) + transform[k + 1]; + } + } + } return data; }, @@ -43614,8 +43643,6 @@ var JpegImage = (function jpegImage() { return true; } else if (this.numComponents == 3) { return true; - } else if (typeof this.colorTransform !== 'undefined') { - return !!this.colorTransform; } else { return false; } diff --git a/build/pdf.js b/build/pdf.js index 798eefe1a..042c743bf 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.288'; -PDFJS.build = '2449142'; +PDFJS.version = '1.0.291'; +PDFJS.build = 'e03ac80'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/build/pdf.worker.js b/build/pdf.worker.js index e2eceb939..7039e9c9c 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.288'; -PDFJS.build = '2449142'; +PDFJS.version = '1.0.291'; +PDFJS.build = 'e03ac80'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -36145,9 +36145,27 @@ var JpegStream = (function JpegStreamClosure() { } try { var jpegImage = new JpegImage(); - if (this.colorTransform != -1) { - jpegImage.colorTransform = this.colorTransform; + + // checking if values needs to be transformed before conversion + if (this.dict && isArray(this.dict.get('Decode'))) { + var decodeArr = this.dict.get('Decode'); + var bitsPerComponent = this.dict.get('BitsPerComponent') || 8; + var decodeArrLength = decodeArr.length; + var transform = new Int32Array(decodeArrLength); + var transformNeeded = false; + var maxValue = (1 << bitsPerComponent) - 1; + for (var i = 0; i < decodeArrLength; i += 2) { + transform[i] = ((decodeArr[i + 1] - decodeArr[i]) * 256) | 0; + transform[i + 1] = (decodeArr[i] * maxValue) | 0; + if (transform[i] !== 256 || transform[i + 1] !== 0) { + transformNeeded = true; + } + } + if (transformNeeded) { + jpegImage.decodeTransform = transform; + } } + jpegImage.parse(this.bytes); var data = jpegImage.getData(this.drawWidth, this.drawHeight, /* forceRGBoutput = */true); @@ -39066,7 +39084,7 @@ var JpegImage = (function jpegImage() { var scaleX = this.width / width, scaleY = this.height / height; var component, componentScaleX, componentScaleY, blocksPerScanline; - var x, y, i, j; + var x, y, i, j, k; var index; var offset = 0; var output; @@ -39098,6 +39116,17 @@ var JpegImage = (function jpegImage() { } } } + + // decodeTransform will contains pairs of multiplier (-256..256) and + // additive + var transform = this.decodeTransform; + if (transform) { + for (i = 0; i < dataLength;) { + for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) { + data[i] = ((data[i] * transform[k]) >> 8) + transform[k + 1]; + } + } + } return data; }, @@ -39107,8 +39136,6 @@ var JpegImage = (function jpegImage() { return true; } else if (this.numComponents == 3) { return true; - } else if (typeof this.colorTransform !== 'undefined') { - return !!this.colorTransform; } else { return false; } diff --git a/package.json b/package.json index 34408390e..00b6794b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.288", + "version": "1.0.291", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla",