add code to parse bits per component information for images

This commit is contained in:
Andreas Gal 2011-06-05 10:56:05 -07:00
parent 378f381625
commit 386d70f33c

15
pdf.js
View File

@ -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;