Browse Source

Merge pull request #6984 from Snuffleupagus/issue-6066

Update `JpegImage.getData` to support `forceRGBoutput` for images with `numComponents === 1` (issue 6066)
Jonas Jenwald 9 years ago
parent
commit
8cdb69634f
  1. 13
      src/core/jpg.js
  2. 1
      test/pdfs/issue6066.pdf.link
  3. 9
      test/test_manifest.json

13
src/core/jpg.js

@ -1019,7 +1019,18 @@ var JpegImage = (function jpegImage() { @@ -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()) {

1
test/pdfs/issue6066.pdf.link

@ -0,0 +1 @@ @@ -0,0 +1 @@
http://web.archive.org/web/20160213124006/http://www.leon.pl/userfiles/file/Zapytanie%20ofertowe%201-2014.pdf

9
test/test_manifest.json

@ -980,6 +980,15 @@ @@ -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",

Loading…
Cancel
Save