[Pkg-javascript-commits] [pdf.js] 217/414: Update `JpegImage.getData` to support `forceRGBoutput` for images with `numComponents === 1` (issue 6066)

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit a494e33776995c3617d07cb8ab7536f3bbbfd280
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Mon Feb 8 13:49:30 2016 +0100

    Update `JpegImage.getData` to support `forceRGBoutput` for images with `numComponents === 1` (issue 6066)
    
    *A more robust solution for issue 6066.*
    
    As a temporary work-around for (the upstream) [bug 1164199](https://bugzilla.mozilla.org/show_bug.cgi?id=1164199), we parsed *all* images in the Firefox addon during a short time.
    Doing so uncovered an issue with our image handling (see 6066), for JPEG images with a `DeviceGray` ColorSpace *and* `bpc !== 1` (bits per component).
    
    As long as we let the browser handle image decoding in this case, this isn't going to be an issue, but I do think that we should proactively fix this to avoid future issues if we change where the images are decoded (in `jpg.js` vs in browser).
    Also, we currently don't seem to have a test-case for that kind of image data.
---
 src/core/jpg.js              | 13 ++++++++++++-
 test/pdfs/issue6066.pdf.link |  1 +
 test/test_manifest.json      |  9 +++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/core/jpg.js b/src/core/jpg.js
index 9840052..be68404 100644
--- a/src/core/jpg.js
+++ b/src/core/jpg.js
@@ -1019,7 +1019,18 @@ var JpegImage = (function jpegImage() {
       // type of data: Uint8Array(width * height * numComponents)
       var data = this._getLinearizedBlockData(width, height);
 
-      if (this.numComponents === 3) {
+      if (this.numComponents === 1 && forceRGBoutput) {
+        var dataLength = data.length;
+        var rgbData = new Uint8Array(dataLength * 3);
+        var offset = 0;
+        for (var i = 0; i < dataLength; i++) {
+          var grayColor = data[i];
+          rgbData[offset++] = grayColor;
+          rgbData[offset++] = grayColor;
+          rgbData[offset++] = grayColor;
+        }
+        return rgbData;
+      } else if (this.numComponents === 3) {
         return this._convertYccToRgb(data);
       } else if (this.numComponents === 4) {
         if (this._isColorConversionNeeded()) {
diff --git a/test/pdfs/issue6066.pdf.link b/test/pdfs/issue6066.pdf.link
new file mode 100644
index 0000000..0aa55bd
--- /dev/null
+++ b/test/pdfs/issue6066.pdf.link
@@ -0,0 +1 @@
+http://web.archive.org/web/20160213124006/http://www.leon.pl/userfiles/file/Zapytanie%20ofertowe%201-2014.pdf
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 589f96b..1bbc7f0 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -980,6 +980,15 @@
        "lastPage": 3,
        "type": "eq"
     },
+    {  "id": "issue6066",
+       "file": "pdfs/issue6066.pdf",
+       "md5": "b26eb08fc5ab2518ba8fde603bdfc46b",
+       "rounds": 1,
+       "link": true,
+       "firstPage": 2,
+       "lastPage": 2,
+       "type": "eq"
+    },
     {  "id": "issue1905",
        "file": "pdfs/issue1905.pdf",
        "md5": "b1bbd72ca6522ae1502aa26320f81994",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list