mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Respect the 'ColorTransform' entry in the image dictionary when decoding JPEG images (bug 956965, issue 6574)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=956965. Fixes 6574.
This commit is contained in:
parent
6c263c1994
commit
116ba19dd9
6 changed files with 56 additions and 15 deletions
|
@ -40,7 +40,7 @@ var error = sharedUtil.error;
|
|||
* (partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf)
|
||||
*/
|
||||
|
||||
var JpegImage = (function jpegImage() {
|
||||
var JpegImage = (function JpegImageClosure() {
|
||||
var dctZigZag = new Uint8Array([
|
||||
0,
|
||||
1, 8,
|
||||
|
@ -68,7 +68,9 @@ var JpegImage = (function jpegImage() {
|
|||
var dctSqrt2 = 5793; // sqrt(2)
|
||||
var dctSqrt1d2 = 2896; // sqrt(2) / 2
|
||||
|
||||
function constructor() {
|
||||
function JpegImage() {
|
||||
this.decodeTransform = null;
|
||||
this.colorTransform = -1;
|
||||
}
|
||||
|
||||
function buildHuffmanTable(codeLengths, values) {
|
||||
|
@ -585,7 +587,7 @@ var JpegImage = (function jpegImage() {
|
|||
return a <= 0 ? 0 : a >= 255 ? 255 : a;
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
JpegImage.prototype = {
|
||||
parse: function parse(data) {
|
||||
|
||||
function readUint16() {
|
||||
|
@ -902,8 +904,20 @@ var JpegImage = (function jpegImage() {
|
|||
// The adobe transform marker overrides any previous setting
|
||||
return true;
|
||||
} else if (this.numComponents === 3) {
|
||||
if (!this.adobe && this.colorTransform === 0) {
|
||||
// If the Adobe transform marker is not present and the image
|
||||
// dictionary has a 'ColorTransform' entry, explicitly set to `0`,
|
||||
// then the colours should *not* be transformed.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
} else { // `this.numComponents !== 3`
|
||||
if (!this.adobe && this.colorTransform === 1) {
|
||||
// If the Adobe transform marker is not present and the image
|
||||
// dictionary has a 'ColorTransform' entry, explicitly set to `1`,
|
||||
// then the colours should be transformed.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
@ -1045,7 +1059,7 @@ var JpegImage = (function jpegImage() {
|
|||
rgbData[offset++] = grayColor;
|
||||
}
|
||||
return rgbData;
|
||||
} else if (this.numComponents === 3) {
|
||||
} else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
|
||||
return this._convertYccToRgb(data);
|
||||
} else if (this.numComponents === 4) {
|
||||
if (this._isColorConversionNeeded()) {
|
||||
|
@ -1062,7 +1076,7 @@ var JpegImage = (function jpegImage() {
|
|||
}
|
||||
};
|
||||
|
||||
return constructor;
|
||||
return JpegImage;
|
||||
})();
|
||||
|
||||
exports.JpegImage = JpegImage;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue