From 073af783070e15863ab688954055d098e4cd8e9c Mon Sep 17 00:00:00 2001 From: Brendan Dahl Date: Wed, 9 Nov 2011 09:29:33 -0800 Subject: [PATCH] Handle device gray and pass in the color transform option. --- src/stream.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/stream.js b/src/stream.js index ce69e96aa..65e122ad0 100644 --- a/src/stream.js +++ b/src/stream.js @@ -797,16 +797,21 @@ var JpegStream = (function jpegStream() { // Flag indicating wether the image can be natively loaded. this.isNative = true; + this.colorTransform = -1; + if (isAdobeImage(bytes)) { // when bug 674619 land, let's check if browser can do // normal cmyk and then we won't have to the following var cs = xref.fetchIfRef(dict.get('ColorSpace')); - if (isName(cs) && cs.name === 'DeviceCMYK') { - this.isNative = false; - this.bytes = bytes; - } else { + + // DeviceRGB and DeviceGray are the only Adobe images that work natively + if (isName(cs) && (cs.name === 'DeviceRGB' || cs.name === 'DeviceGray')) { bytes = fixAdobeImage(bytes); this.src = bytesToString(bytes); + } else { + this.colorTransform = dict.get('ColorTransform'); + this.isNative = false; + this.bytes = bytes; } } else { this.src = bytesToString(bytes); @@ -820,7 +825,7 @@ var JpegStream = (function jpegStream() { constructor.prototype.ensureBuffer = function jpegStreamEnsureBuffer(req) { if (this.bufferLength) return; - var jpegImage = new JpegImage(); + var jpegImage = new JpegImage(this.colorTransform); jpegImage.parse(this.bytes); var width = jpegImage.width; var height = jpegImage.height;