]> git.parisson.com Git - pdf.js.git/commitdiff
Handle device gray and pass in the color transform option.
authorBrendan Dahl <brendan.dahl@gmail.com>
Wed, 9 Nov 2011 17:29:33 +0000 (09:29 -0800)
committerBrendan Dahl <brendan.dahl@gmail.com>
Wed, 9 Nov 2011 17:29:33 +0000 (09:29 -0800)
src/stream.js

index ce69e96aa5b1e00de39bb42df74d10cc9bae4bb7..65e122ad0d6a02a6493d62f98d3f34b605f4c562 100644 (file)
@@ -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;