1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Use the Alternate entry, if it exists, in ICCBased Colour Space dictionaries (issue 5836, issue 5939, issue 6055)

Fixes 5836.
Fixes 5939.
Fixes 6055.
This commit is contained in:
Jonas Jenwald 2015-06-13 21:05:13 +02:00
parent bf20334bea
commit bc5e43b45c
3 changed files with 24 additions and 3 deletions

View file

@ -262,7 +262,7 @@ var ColorSpace = (function ColorSpaceClosure() {
} else if (isArray(cs)) {
mode = xref.fetchIfRef(cs[0]).name;
this.mode = mode;
var numComps, params;
var numComps, params, alt;
switch (mode) {
case 'DeviceGray':
@ -284,6 +284,17 @@ var ColorSpace = (function ColorSpaceClosure() {
var stream = xref.fetchIfRef(cs[1]);
var dict = stream.dict;
numComps = dict.get('N');
alt = dict.get('Alternate');
if (alt) {
var altIR = ColorSpace.parseToIR(alt, xref, res);
// Parse the /Alternate CS to ensure that the number of components
// are correct, and also (indirectly) that it is not a PatternCS.
var altCS = ColorSpace.fromIR(altIR);
if (altCS.numComps === numComps) {
return altIR;
}
warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
}
if (numComps === 1) {
return 'DeviceGrayCS';
} else if (numComps === 3) {
@ -316,11 +327,11 @@ var ColorSpace = (function ColorSpaceClosure() {
} else if (isArray(name)) {
numComps = name.length;
}
var alt = ColorSpace.parseToIR(cs[2], xref, res);
alt = ColorSpace.parseToIR(cs[2], xref, res);
var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
return ['AlternateCS', numComps, alt, tintFnIR];
case 'Lab':
params = cs[1].getAll();
params = xref.fetchIfRef(cs[1]).getAll();
return ['LabCS', params];
default:
error('unimplemented color space object "' + mode + '"');