From: Andreas Gal Date: Sun, 5 Jun 2011 17:56:05 +0000 (-0700) Subject: add code to parse bits per component information for images X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=386d70f33cf91576f4563d7d378466e9a3980e85;p=pdf.js.git add code to parse bits per component information for images --- diff --git a/pdf.js b/pdf.js index 96dc518..0d377d1 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;