From 386d70f33cf91576f4563d7d378466e9a3980e85 Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Sun, 5 Jun 2011 10:56:05 -0700 Subject: [PATCH] add code to parse bits per component information for images --- pdf.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pdf.js b/pdf.js index 96dc518b5..0d377d139 100644 --- 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;