]> git.parisson.com Git - pdf.js.git/commitdiff
add code to parse bits per component information for images
authorAndreas Gal <andreas.gal@gmail.com>
Sun, 5 Jun 2011 17:56:05 +0000 (10:56 -0700)
committerAndreas Gal <andreas.gal@gmail.com>
Sun, 5 Jun 2011 17:56:05 +0000 (10:56 -0700)
pdf.js

diff --git a/pdf.js b/pdf.js
index 96dc518b5108c0e4a80956a7f71b61d952c320ff..0d377d13932281fa54e450ead6e25db2bf73033c 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -1904,6 +1904,21 @@ var CanvasGraphics = (function() {
             if (!IsBool(imageMask))
                 imageMask = false;
 
+            // JPX/JPEG2000 streams directly contain bits per component
+            // and color space mode information.
+            var bitsPerComponent = image.bitsPerComponent;
+            var csMode = image.csMode;
+
+            if (!bitsPerComponent) {
+                bitsPerComponent = dict.get("BitsPerComponent") || dict.get("BPC");
+                if (!bitsPerComponent) {
+                    if (imageMask)
+                        bitsPerComponent = 1;
+                    else
+                        error("Bits per component missing in image");
+                }
+            }
+
             var tmpCanvas = document.createElement("canvas");
             tmpCanvas.width = w;
             tmpCanvas.height = h;