From fcbe4f13d100faee0c7da461601a6ae4811c797a Mon Sep 17 00:00:00 2001 From: Artur Adib Date: Thu, 8 Dec 2011 18:19:36 -0500 Subject: [PATCH] More sanity checks --- src/image.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/image.js b/src/image.js index 57c6d415f..f24d28638 100644 --- a/src/image.js +++ b/src/image.js @@ -200,7 +200,7 @@ var PDFImage = (function pdfImage() { // Is there a one-to-one correspondence between pixels in the loop below? if (length !== 4*comps.length/3) - error('Number of image pixels mismatch'); + error('Number of image pixels mismatch (RGB)'); for (var i = 0; i < length; i += 4) { buffer[i] = comps[compsPos++]; @@ -226,6 +226,10 @@ var PDFImage = (function pdfImage() { var comps = this.getComponents(imgArray); var length = width * height; + // Is there a one-to-one correspondence between pixels in the loop below? + if (length !== comps.length) + error('Number of image pixels mismatch (Gray)'); + for (var i = 0; i < length; ++i) buffer[i] = comps[i]; }